Skip to content

Commit

Permalink
[win32] strict check to identify long running GC
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akoch-yatta authored and HeikoKlare committed Feb 5, 2025
1 parent 9d3673c commit 81ac825
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,28 @@ static int checkStyle(int style) {
return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
}

private void validateGCState() {
if (drawable == null) {
return;
}
try {
GCData newData = new GCData();
long newHdc = drawable.internal_new_GC(newData);

if (data.nativeZoom != newData.nativeZoom) {
System.err.println("***WARNING: Zoom of the underlying Drawable of the GC has changed. This indicates a "
+ "long running GC that should be recreated.");
}
drawable.internal_dispose_GC(newHdc, newData);
} catch (Exception e) {
// ignore if recreation fails
}
}

void checkGC(int mask) {
if (Device.strictChecks) {
validateGCState();
}
int state = data.state;
if ((state & mask) == mask) return;
state = (state ^ mask) & mask;
Expand Down

0 comments on commit 81ac825

Please sign in to comment.