Skip to content

Commit a1c947d

Browse files
committed
[win32] Add internal strict mode flag for GC
This contribution adds a strict mode flag configurable via system property to GC the print our errors, if the GC is not configured correctly for the monitor-specific-scaling
1 parent 60ef7e9 commit a1c947d

File tree

1 file changed

+18
-0
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

1 file changed

+18
-0
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@ public final class GC extends Resource {
102102
static final float[] LINE_DASHDOT_ZERO = new float[]{9, 6, 3, 6};
103103
static final float[] LINE_DASHDOTDOT_ZERO = new float[]{9, 3, 3, 3, 3, 3};
104104

105+
/**
106+
* System property to activate a strict mode for GC, which outputs errors for misconfigured GCs.
107+
* <ul>
108+
* <li><b>true</b>: Enables additional checks and prints errors if an invalid configuration is detected.
109+
* This mode should only be used during development.</li>
110+
* <li><b>false</b>: No additional checks are executed.</li>
111+
* </ul>
112+
* <b>Important:</b> This flag is currently only used on Win32. Setting it to
113+
* true on GTK or cocoa wont have any effect.
114+
* <p>
115+
* The current default is "false".
116+
*/
117+
private static final String GC_STRICT_MODE = "gc.strict";
118+
105119
/**
106120
* Prevents uninitialized instances from being created outside the package.
107121
*/
@@ -3950,6 +3964,10 @@ void init(Drawable drawable, GCData data, long hDC) {
39503964
}
39513965

39523966
private static int extractZoom(long hDC) {
3967+
if (Boolean.getBoolean (GC_STRICT_MODE)) {
3968+
System.err.println("***WARNING: GC is initialized with a missing zoom. It was probably instantiated with a "
3969+
+ "custom Drawable implementation and show be configured in internal_new_GC");
3970+
}
39533971
long hwnd = OS.WindowFromDC(hDC);
39543972
long parentWindow = OS.GetAncestor(hwnd, OS.GA_ROOT);
39553973
long monitorParent = OS.MonitorFromWindow(parentWindow, OS.MONITOR_DEFAULTTONEAREST);

0 commit comments

Comments
 (0)