xdg-open now runs outside of the GtkEventDispatch thread

This commit is contained in:
nathan 2017-09-28 21:07:39 +02:00
parent 7124bb3b5e
commit 48511eebb3

View File

@ -78,26 +78,28 @@ class Desktop {
// Additionally, xdg-open can cause problems in Linux with Chrome installed but not the default browser. It will crash Chrome // Additionally, xdg-open can cause problems in Linux with Chrome installed but not the default browser. It will crash Chrome
// if Chrome was open before this app opened a URL // if Chrome was open before this app opened a URL
if ((OS.isUnix() || OS.isLinux()) && GtkCheck.isGtkLoaded) { if ((OS.isUnix() || OS.isLinux()) && GtkCheck.isGtkLoaded) {
GtkEventDispatch.dispatch(new Runnable() { // there are problems with ubuntu and practically everything. Errors galore, and sometimes things don't even work.
@Override // see: https://bugzilla.mozilla.org/show_bug.cgi?id=672671
public if (OSUtil.DesktopEnv.isUnity() && OSUtil.Linux.isUbuntu()) {
void run() { // use xdg-open, because it launches in a new shell and suppresses these errors/warnings.
// there are problems with ubuntu and practically everything. Errors galore, and sometimes things don't even work. // it can be really buggy though, so we only use it for ubuntu...
// see: https://bugzilla.mozilla.org/show_bug.cgi?id=672671 ShellExecutor.run("xdg-open", uri.toString());
if (OSUtil.DesktopEnv.isUnity() && OSUtil.Linux.isUbuntu()) { }
// use xdg-open, because it launches in a new shell and suppresses these errors/warnings. else {
// it can be really buggy though, so we only use it for ubuntu... GtkEventDispatch.dispatch(new Runnable() {
ShellExecutor.run("xdg-open", uri.toString()); @Override
public
void run() {
if (GtkCheck.gtkIsGreaterOrEqual(3, 22, 0)) {
Pointer pointer = Gtk2.Gtk2.gdk_display_get_default();
Gtk3.Gtk3.gtk_show_uri_on_window(pointer, uri.toString(), 0, null);
}
else {
Gtk2.Gtk2.gtk_show_uri(Gtk2.Gtk2.gdk_screen_get_default(), uri.toString(), 0, null);
}
} }
else if (GtkCheck.gtkIsGreaterOrEqual(3, 22, 0)) { });
Pointer pointer = Gtk2.Gtk2.gdk_display_get_default(); }
Gtk3.Gtk3.gtk_show_uri_on_window(pointer, uri.toString(), 0, null);
}
else {
Gtk2.Gtk2.gtk_show_uri(Gtk2.Gtk2.gdk_screen_get_default(), uri.toString(), 0, null);
}
}
});
} }
else if (java.awt.Desktop.isDesktopSupported() && java.awt.Desktop.getDesktop() else if (java.awt.Desktop.isDesktopSupported() && java.awt.Desktop.getDesktop()
.isSupported(java.awt.Desktop.Action.BROWSE)) { .isSupported(java.awt.Desktop.Action.BROWSE)) {
@ -211,26 +213,28 @@ class Desktop {
} }
final String finalPath = path; final String finalPath = path;
GtkEventDispatch.dispatch(new Runnable() { // there are problems with ubuntu and practically everything. Errors galore, and sometimes things don't even work.
@Override // see: https://askubuntu.com/questions/788182/nautilus-not-opening-up-showing-glib-error
public if (OSUtil.DesktopEnv.isUnity() && OSUtil.Linux.isUbuntu()) {
void run() { // use xdg-open, because it launches in a new shell and suppresses these errors/warnings.
// there are problems with ubuntu and practically everything. Errors galore, and sometimes things don't even work. // it can be really buggy though, so we only use it for ubuntu...
// see: https://askubuntu.com/questions/788182/nautilus-not-opening-up-showing-glib-error ShellExecutor.runShell("xdg-open", finalPath);
if (OSUtil.DesktopEnv.isUnity() && OSUtil.Linux.isUbuntu()) { }
// use xdg-open, because it launches in a new shell and suppresses these errors/warnings. else {
// it can be really buggy though, so we only use it for ubuntu... GtkEventDispatch.dispatch(new Runnable() {
ShellExecutor.runShell("xdg-open", finalPath); @Override
public
void run() {
if (GtkCheck.gtkIsGreaterOrEqual(3, 22, 0)) {
Pointer pointer = Gtk2.Gtk2.gdk_display_get_default();
Gtk3.Gtk3.gtk_show_uri_on_window(pointer, finalPath, 0, null);
}
else {
Gtk2.Gtk2.gtk_show_uri(Gtk2.Gtk2.gdk_screen_get_default(), finalPath, 0, null);
}
} }
else if (GtkCheck.gtkIsGreaterOrEqual(3, 22, 0)) { });
Pointer pointer = Gtk2.Gtk2.gdk_display_get_default(); }
Gtk3.Gtk3.gtk_show_uri_on_window(pointer, finalPath, 0, null);
}
else {
Gtk2.Gtk2.gtk_show_uri(Gtk2.Gtk2.gdk_screen_get_default(), finalPath, 0, null);
}
}
});
} }
else if (java.awt.Desktop.isDesktopSupported() && java.awt.Desktop.getDesktop() else if (java.awt.Desktop.isDesktopSupported() && java.awt.Desktop.getDesktop()
.isSupported(java.awt.Desktop.Action.OPEN)) { .isSupported(java.awt.Desktop.Action.OPEN)) {