catching openURL() issues on macOS

This commit is contained in:
Ben Fry
2016-11-06 21:27:25 -05:00
parent 8f1ce4d213
commit 9df210b7d4
2 changed files with 19 additions and 0 deletions

View File

@@ -22,9 +22,11 @@
package processing.app.platform;
import java.awt.Desktop;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import com.apple.eio.FileManager;
@@ -62,6 +64,7 @@ public class MacPlatform extends DefaultPlatform {
}
}
public void initBase(Base base) {
super.initBase(base);
System.setProperty("apple.laf.useScreenMenuBar", "true");
@@ -127,6 +130,21 @@ public class MacPlatform extends DefaultPlatform {
// }
public void openURL(String url) throws Exception {
try {
Desktop.getDesktop().browse(new URI(url));
} catch (IOException e) {
// Deal with a situation where the browser hangs on macOS
// https://github.com/fathominfo/processing-p5js-mode/issues/4
if (e.getMessage().contains("Error code: -600")) {
throw new RuntimeException("Could not open the sketch, please restart your browser or computer");
} else {
throw e;
}
}
}
/*
public void openURL(String url) throws Exception {
if (PApplet.javaVersion < 1.6f) {

View File

@@ -2579,6 +2579,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
Preferences.save();
}
/**
* Set the title of the PDE window based on the current sketch, i.e.
* something like "sketch_070752a - Processing 0126"