mirror of
https://github.com/processing/processing4.git
synced 2026-02-04 06:09:17 +01:00
catching openURL() issues on macOS
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user