Skip to content

Commit 81ac825

Browse files
akoch-yattaHeikoKlare
authored andcommitted
[win32] strict check to identify long running GC
This commit adds a check to identify long running or misconfigured GCs that render in a different zoom as its creating drawable intended to. Only executes if strict checking is enabled.
1 parent 9d3673c commit 81ac825

File tree

1 file changed

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

1 file changed

+21
-0
lines changed

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

+21
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,28 @@ static int checkStyle(int style) {
182182
return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
183183
}
184184

185+
private void validateGCState() {
186+
if (drawable == null) {
187+
return;
188+
}
189+
try {
190+
GCData newData = new GCData();
191+
long newHdc = drawable.internal_new_GC(newData);
192+
193+
if (data.nativeZoom != newData.nativeZoom) {
194+
System.err.println("***WARNING: Zoom of the underlying Drawable of the GC has changed. This indicates a "
195+
+ "long running GC that should be recreated.");
196+
}
197+
drawable.internal_dispose_GC(newHdc, newData);
198+
} catch (Exception e) {
199+
// ignore if recreation fails
200+
}
201+
}
202+
185203
void checkGC(int mask) {
204+
if (Device.strictChecks) {
205+
validateGCState();
206+
}
186207
int state = data.state;
187208
if ((state & mask) == mask) return;
188209
state = (state ^ mask) & mask;

0 commit comments

Comments
 (0)