Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita Nemkin2019-03-28 12:34:15 -0400
committerLars Vogel2019-04-15 05:35:57 -0400
commit44ae0603eb815357cbc63a475955dc0268f4623d (patch)
treecd27f8fbc6f18b9b6381749acf2ed4dccf61245c
parentd9768fbd136dc5773bddc1fdd707d09933dec747 (diff)
downloadeclipse.platform.swt-44ae0603eb815357cbc63a475955dc0268f4623d.tar.gz
eclipse.platform.swt-44ae0603eb815357cbc63a475955dc0268f4623d.tar.xz
eclipse.platform.swt-44ae0603eb815357cbc63a475955dc0268f4623d.zip
Bug 546420 - [Win32] Don't guard against GDI+ loading failure
GDI+ presence is guaranteed on WinXP and later. Change-Id: Iee3c46ce8a2ac61170a51b06d7986340051ca1c8 Signed-off-by: Nikita Nemkin <nikita@nemkin.ru>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java6
3 files changed, 19 insertions, 33 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
index aa27ead398..f4d6cdf57f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
@@ -189,32 +189,24 @@ protected void checkDevice () {
void checkGDIP() {
if (gdipToken != null) return;
- int oldErrorMode = OS.SetErrorMode (OS.SEM_FAILCRITICALERRORS);
- try {
- long /*int*/ [] token = new long /*int*/ [1];
- GdiplusStartupInput input = new GdiplusStartupInput ();
- input.GdiplusVersion = 1;
- if (Gdip.GdiplusStartup (token, input, 0) == 0) {
- gdipToken = token;
- if (loadedFonts != null) {
- fontCollection = Gdip.PrivateFontCollection_new();
- if (fontCollection == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- for (int i = 0; i < loadedFonts.length; i++) {
- String path = loadedFonts[i];
- if (path == null) break;
- int length = path.length();
- char [] buffer = new char [length + 1];
- path.getChars(0, length, buffer, 0);
- Gdip.PrivateFontCollection_AddFontFile(fontCollection, buffer);
- }
- loadedFonts = null;
- }
+ long /*int*/ [] token = new long /*int*/ [1];
+ GdiplusStartupInput input = new GdiplusStartupInput ();
+ input.GdiplusVersion = 1;
+ if (Gdip.GdiplusStartup (token, input, 0) != 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ gdipToken = token;
+ if (loadedFonts != null) {
+ fontCollection = Gdip.PrivateFontCollection_new();
+ if (fontCollection == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ for (int i = 0; i < loadedFonts.length; i++) {
+ String path = loadedFonts[i];
+ if (path == null) break;
+ int length = path.length();
+ char [] buffer = new char [length + 1];
+ path.getChars(0, length, buffer, 0);
+ Gdip.PrivateFontCollection_AddFontFile(fontCollection, buffer);
}
- } catch (Throwable t) {
- SWT.error (SWT.ERROR_NO_GRAPHICS_LIBRARY, t, " [GDI+ is required]"); //$NON-NLS-1$
- } finally {
- OS.SetErrorMode (oldErrorMode);
- }
+ loadedFonts = null;
+ }
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
index 9671da2438..44350b9454 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
@@ -4003,9 +4003,7 @@ public void setAdvanced(boolean advanced) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (advanced && data.gdipGraphics != 0) return;
if (advanced) {
- try {
- initGdip();
- } catch (SWTException e) {}
+ initGdip();
} else {
disposeGdip();
data.alpha = 0xFF;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
index 86c7ce5ce4..f4bac26440 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
@@ -807,12 +807,8 @@ boolean refreshImageForZoom () {
}
void initNative(String filename) {
+ device.checkGDIP();
boolean gdip = true;
- try {
- device.checkGDIP();
- } catch (SWTException e) {
- gdip = false;
- }
/*
* Bug in GDI+. For some reason, Bitmap.LockBits() segment faults
* when loading GIF files in 64-bit Windows. The fix is to not use

Back to the top