Skip to content

Commit 9196a8d

Browse files
Don't show the GUI on --verify or --upload
These are intended to be ran from the commandline, so showing the GUI doesn't make so much sense. This is not quite the perfect solution yet, because an Editor object and all kinds of GUI objects are still created. This commit only prevents them from being visible, which is a nice first step, but not quite pretty yet. However, to do it properly, some code should be moved out of the Editor class, so that's a bit more work. Additionally, any messages shown with Base::showError and friends still create a popup, they probably shouldn't do this either.
1 parent c6795dd commit 9196a8d

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

app/src/processing/app/Base.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ public Base(String[] args) throws Exception {
399399
path = new File(currentDirectory, path).getAbsolutePath();
400400
}
401401

402-
if (handleOpen(path) == null) {
402+
if (handleOpen(path, nextEditorLocation(), !(doUpload || doVerify)) == null) {
403403
String mess = I18n.format(_("Failed to open sketch: \"{0}\""), path);
404404
// Open failure is fatal in upload/verify mode
405405
if (doUpload || doVerify)
@@ -416,10 +416,6 @@ public Base(String[] args) throws Exception {
416416

417417
Editor editor = editors.get(0);
418418

419-
// Wait until editor is initialized
420-
while (!editor.status.isInitialized())
421-
Thread.sleep(10);
422-
423419
// Do board selection if requested
424420
processBoardArgument(selectBoard);
425421

@@ -574,7 +570,7 @@ protected boolean restoreSketches() throws Exception {
574570
location = nextEditorLocation();
575571
}
576572
// If file did not exist, null will be returned for the Editor
577-
if (handleOpen(path, location) != null) {
573+
if (handleOpen(path, location, true) != null) {
578574
opened++;
579575
}
580576
}
@@ -888,11 +884,11 @@ public void handleOpenPrompt() throws Exception {
888884
* @throws Exception
889885
*/
890886
public Editor handleOpen(String path) throws Exception {
891-
return handleOpen(path, nextEditorLocation());
887+
return handleOpen(path, nextEditorLocation(), true);
892888
}
893889

894890

895-
protected Editor handleOpen(String path, int[] location) throws Exception {
891+
protected Editor handleOpen(String path, int[] location, boolean showEditor) throws Exception {
896892
// System.err.println("entering handleOpen " + path);
897893

898894
File file = new File(path);
@@ -960,7 +956,8 @@ protected Editor handleOpen(String path, int[] location) throws Exception {
960956

961957
// now that we're ready, show the window
962958
// (don't do earlier, cuz we might move it based on a window being closed)
963-
editor.setVisible(true);
959+
if (showEditor)
960+
editor.setVisible(true);
964961

965962
// System.err.println("exiting handleOpen");
966963

app/src/processing/app/EditorStatus.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ public void empty() {
113113
public void notice(String message) {
114114
mode = NOTICE;
115115
this.message = message;
116-
copyErrorButton.setVisible(false);
116+
if (copyErrorButton != null)
117+
copyErrorButton.setVisible(false);
117118
//update();
118119
repaint();
119120
}
@@ -126,7 +127,8 @@ public void unnotice(String unmessage) {
126127
public void error(String message) {
127128
mode = ERR;
128129
this.message = message;
129-
copyErrorButton.setVisible(true);
130+
if (copyErrorButton != null)
131+
copyErrorButton.setVisible(true);
130132
repaint();
131133
}
132134

0 commit comments

Comments
 (0)