diff options
author | Sravan Kumar Lakkimsetti | 2015-03-05 16:48:12 +0000 |
---|---|---|
committer | Sravan Kumar Lakkimsetti | 2015-03-05 16:48:12 +0000 |
commit | c9ba0073171d2b3ea70da85754794f57d1358a36 (patch) | |
tree | e11189560b1b20f6802a8c5e6f05a1c9deb72e4a | |
parent | c3553499426625bffb4358d5d34f876eb2bd4a66 (diff) | |
download | eclipse.platform.swt-c9ba0073171d2b3ea70da85754794f57d1358a36.tar.gz eclipse.platform.swt-c9ba0073171d2b3ea70da85754794f57d1358a36.tar.xz eclipse.platform.swt-c9ba0073171d2b3ea70da85754794f57d1358a36.zip |
Added error check for file existence
Change-Id: I9f901f07542216a7fbe1a98f8c9ea35db3822f37
Signed-off-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/DpiUtil.java | 19 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java | 4 |
2 files changed, 19 insertions, 4 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/DpiUtil.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/DpiUtil.java index 70e266c4d6..18e20aa84f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/DpiUtil.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/DpiUtil.java @@ -10,6 +10,8 @@ *******************************************************************************/
package org.eclipse.swt.graphics;
+import java.io.*;
+
/**
* This class hold common constants and utility functions w.r.t. to SWT high DPI
* functionality.
@@ -27,7 +29,7 @@ public class DpiUtil { *
* @return String[] image filenames
*/
- public static String[] getImageNames (String fileName) {
+ static String[] getImageNames (String fileName) {
if (fileName == null || fileName.trim().length() == 0)
return new String[0];
@@ -51,7 +53,7 @@ public class DpiUtil { *
* @return imageSelector index
*/
- public static int mapDpiToImageSelectorIndex (int dpi) {
+ static int mapDpiToImageSelectorIndex (int dpi) {
int imageSelectorIndex;
if (dpi >= 192) {
imageSelectorIndex = 2;
@@ -68,7 +70,7 @@ public class DpiUtil { *
* @return imageSelector index
*/
- public static int mapZoomToImageSelectorIndex (int zoom) {
+ static int mapZoomToImageSelectorIndex (int zoom) {
int imageSelectorIndex = 0;
switch (zoom) {
case 200:
@@ -84,4 +86,15 @@ public class DpiUtil { }
return imageSelectorIndex;
}
+
+ static boolean fileExists (String filename) {
+ if (filename == null) {
+ return false;
+ }
+ File f = new File (filename);
+ if (( f.exists() ) && (!f.isDirectory())) {
+ return true;
+ }
+ return false;
+ }
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java index 382b80211f..383b8819b1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java @@ -1746,7 +1746,8 @@ void copyImageDataFromDpiImageStorage (int imageSelectorIndex) { * load the image from the file name */ String filename = dpiFilename[imageSelectorIndex]; - if (filename == null) { + + if (!DpiUtil.fileExists(filename)) { filename = dpiFilename[0]; } if (filename != null) { @@ -1761,6 +1762,7 @@ void copyImageDataFromDpiImageStorage (int imageSelectorIndex) { surface = dpiSurface[0]; } } + createAlphaMask(width, height); } void copyImageDataToDpiImageStorage (int imageSelectorIndex) { |