Better checks when constructing the internal system tray class
This commit is contained in:
parent
077a53d30e
commit
1b25101bef
|
@ -1054,18 +1054,8 @@ class SystemTray {
|
||||||
systemTray = new SystemTray();
|
systemTray = new SystemTray();
|
||||||
|
|
||||||
// AWT/Swing must be constructed on the EDT however...
|
// AWT/Swing must be constructed on the EDT however...
|
||||||
if (JavaFX.isLoaded ||
|
if (!JavaFX.isLoaded && !Swt.isLoaded &&
|
||||||
Swt.isLoaded ||
|
(isTrayType(trayType, TrayType.Swing) || isTrayType(trayType, TrayType.AWT))) {
|
||||||
(isNix && (isTrayType(trayType, TrayType.GtkStatusIcon) || isTrayType(trayType, TrayType.AppIndicator))) ||
|
|
||||||
isTrayType(trayType, TrayType.WindowsNotifyIcon)) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
reference.set((Tray) trayType.getConstructors()[0].newInstance(systemTray));
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Unable to create tray type: '" + trayType.getSimpleName() + "'", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (isTrayType(trayType, TrayType.Swing) || isTrayType(trayType, TrayType.AWT)) {
|
|
||||||
// have to construct swing stuff inside the swing EDT
|
// have to construct swing stuff inside the swing EDT
|
||||||
final Class<? extends Menu> finalTrayType = trayType;
|
final Class<? extends Menu> finalTrayType = trayType;
|
||||||
SwingUtil.invokeAndWait(new Runnable() {
|
SwingUtil.invokeAndWait(new Runnable() {
|
||||||
|
@ -1081,7 +1071,11 @@ class SystemTray {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.error("Unable to create tray type: '{}'. Aborting!", trayType.getSimpleName());
|
try {
|
||||||
|
reference.set((Tray) trayType.getConstructors()[0].newInstance(systemTray));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Unable to create tray type: '" + trayType.getSimpleName() + "'", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Unable to create tray type: '{}'", trayType.getSimpleName(), e);
|
logger.error("Unable to create tray type: '{}'", trayType.getSimpleName(), e);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user