Handle missing resource in loadSwtImage

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2241 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2014-03-10 14:15:38 +00:00
parent c3dabcdfe4
commit 1b7ae604fc
1 changed files with 4 additions and 1 deletions

View File

@ -160,6 +160,9 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
try { try {
ClassLoader classloader = DavGatewayTray.class.getClassLoader(); ClassLoader classloader = DavGatewayTray.class.getClassLoader();
URL imageUrl = classloader.getResource(fileName); URL imageUrl = classloader.getResource(fileName);
if (imageUrl == null) {
throw new IOException(fileName);
}
result = new Image(display, imageUrl.openStream()); result = new Image(display, imageUrl.openStream());
} catch (IOException e) { } catch (IOException e) {
DavGatewayTray.warn(new BundleMessage("LOG_UNABLE_TO_LOAD_IMAGE"), e); DavGatewayTray.warn(new BundleMessage("LOG_UNABLE_TO_LOAD_IMAGE"), e);
@ -180,7 +183,7 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
final String systemLookAndFeelClassName = UIManager.getSystemLookAndFeelClassName(); final String systemLookAndFeelClassName = UIManager.getSystemLookAndFeelClassName();
try { try {
// workaround for bug when SWT and AWT both try to access Gtk // workaround for bug when SWT and AWT both try to access Gtk
if (systemLookAndFeelClassName.indexOf("gtk") >= 0) { if (systemLookAndFeelClassName.contains("gtk")) {
System.setProperty("swing.defaultlaf", UIManager.getCrossPlatformLookAndFeelClassName()); System.setProperty("swing.defaultlaf", UIManager.getCrossPlatformLookAndFeelClassName());
} else { } else {
System.setProperty("swing.defaultlaf", systemLookAndFeelClassName); System.setProperty("swing.defaultlaf", systemLookAndFeelClassName);