Skip to content

Commit

Permalink
Merge pull request #2 from sampottinger/master
Browse files Browse the repository at this point in the history
Sync to master processing while working on processing#5753 / processing#5750
  • Loading branch information
sampottinger committed Jan 18, 2019
2 parents f68fd9e + 46d25b9 commit a12fa6a
Show file tree
Hide file tree
Showing 27 changed files with 817 additions and 253 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*~
/build/shared/reference.zip

# temporary, until we complete the move to IntelliJ
*.iml
/.idea

# via https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
Expand Down
48 changes: 48 additions & 0 deletions app/src/processing/app/RunnerListenerEdtAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package processing.app;

import java.awt.EventQueue;

public class RunnerListenerEdtAdapter implements RunnerListener {

private RunnerListener wrapped;

public RunnerListenerEdtAdapter(RunnerListener wrapped) {
this.wrapped = wrapped;
}

@Override
public void statusError(String message) {
EventQueue.invokeLater(() -> wrapped.statusError(message));
}

@Override
public void statusError(Exception exception) {
EventQueue.invokeLater(() -> wrapped.statusError(exception));
}

@Override
public void statusNotice(String message) {
EventQueue.invokeLater(() -> wrapped.statusNotice(message));
}

@Override
public void startIndeterminate() {
EventQueue.invokeLater(() -> wrapped.startIndeterminate());
}

@Override
public void stopIndeterminate() {
EventQueue.invokeLater(() -> wrapped.stopIndeterminate());
}

@Override
public void statusHalt() {
EventQueue.invokeLater(() -> wrapped.statusHalt());
}

@Override
public boolean isHalted() {
return wrapped.isHalted();
}
}

44 changes: 27 additions & 17 deletions app/src/processing/app/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public class Sketch {
/** Moved out of Editor and into here for cleaner access. */
private boolean untitled;

/** true if we've posted a "sketch disappeared" warning */
private boolean disappearedWarning;

/**
* Used by the command-line version to create a sketch object.
Expand Down Expand Up @@ -123,6 +125,7 @@ protected void load(String path) {
int suffixLength = mode.getDefaultExtension().length() + 1;
name = mainFilename.substring(0, mainFilename.length() - suffixLength);
folder = new File(new File(path).getParent());
disappearedWarning = false;
load();
}

Expand Down Expand Up @@ -1197,6 +1200,7 @@ protected void updateInternal(String sketchName, File sketchFolder) {

name = sketchName;
folder = sketchFolder;
disappearedWarning = false;
codeFolder = new File(folder, "code");
dataFolder = new File(folder, "data");

Expand Down Expand Up @@ -1498,28 +1502,34 @@ public void prepareBuild(File targetFolder) throws SketchException {


/**
* Make sure the sketch hasn't been moved or deleted by some
* nefarious user. If they did, try to re-create it and save.
* Only checks to see if the main folder is still around,
* but not its contents.
* Make sure the sketch hasn't been moved or deleted by a nefarious user.
* If they did, try to re-create it and save. Only checks whether the
* main folder is still around, but not its contents.
*/
public void ensureExistence() {
if (!folder.exists()) {
// Disaster recovery, try to salvage what's there already.
Messages.showWarning(Language.text("ensure_exist.messages.missing_sketch"),
Language.text("ensure_exist.messages.missing_sketch.description"));
try {
folder.mkdirs();
modified = true;
// Avoid an infinite loop if we've already warned about this
// https://github.com/processing/processing/issues/4805
if (!disappearedWarning) {
disappearedWarning = true;

// Disaster recovery, try to salvage what's there already.
Messages.showWarning(Language.text("ensure_exist.messages.missing_sketch"),
Language.text("ensure_exist.messages.missing_sketch.description"));
try {
folder.mkdirs();
modified = true;

for (int i = 0; i < codeCount; i++) {
code[i].save(); // this will force a save
}
calcModified();

for (int i = 0; i < codeCount; i++) {
code[i].save(); // this will force a save
} catch (Exception e) {
// disappearedWarning prevents infinite loop in this scenario
Messages.showWarning(Language.text("ensure_exist.messages.unrecoverable"),
Language.text("ensure_exist.messages.unrecoverable.description"), e);
}
calcModified();

} catch (Exception e) {
Messages.showWarning(Language.text("ensure_exist.messages.unrecoverable"),
Language.text("ensure_exist.messages.unrecoverable.description"), e);
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions app/src/processing/app/SketchException.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ public void hideStackTrace() {
}


public boolean isStackTraceEnabled() {
return showStackTrace;
}


/**
* Nix the java.lang crap out of an exception message
* because it scares the children.
Expand Down
22 changes: 22 additions & 0 deletions app/src/processing/app/ui/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,17 @@ public BasicSplitPaneDivider createDefaultDivider() {
status = new EditorStatus(this, Editor.this);
return status;
}


@Override
public void finishDraggingTo(int location) {
super.finishDraggingTo(location);
// JSplitPane issue: if you only make the lower component visible at
// the last minute, its minmum size is ignored.
if (location > splitPane.getMaximumDividerLocation()) {
splitPane.setDividerLocation(splitPane.getMaximumDividerLocation());
}
}
});

box.add(splitPane);
Expand Down Expand Up @@ -2900,6 +2911,17 @@ public void statusError(Exception e) {

if (e instanceof SketchException) {
SketchException re = (SketchException) e;

// Make sure something is printed into the console
// Status bar is volatile
if (!re.isStackTraceEnabled()) {
System.err.println(re.getMessage());
}

// Move the cursor to the line before updating the status bar, otherwise
// status message might get hidden by a potential message caused by moving
// the cursor to a line with warning in it

if (re.hasCodeIndex()) {
sketch.setCurrentCode(re.getCodeIndex());
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/processing/app/ui/EditorConsole.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ public void message(String what, boolean err) {
// https://github.com/processing/processing/issues/5462
// Some discussion on the Apple's developer forums seems to suggest that is not serious:
// https://forums.developer.apple.com/thread/105244
} else if (err && what.contains("NSWindow drag regions should only be invalidated on the Main Thread")) {
// Keep hiding warnings triggered by JOGL on recent macOS versions (this is from 10.14 onwards I think).
} else if (err && what.contains("Make pbuffer:")) {
// Remove initalization warning from LWJGL.
} else if (err && what.contains("XInitThreads() called for concurrent")) {
Expand Down

0 comments on commit a12fa6a

Please sign in to comment.