Skip to content

Commit a972e2e

Browse files
authored
Fix macOS crash from double-restore in PDFDocument.internal_dispose_GC
1 parent d27eb11 commit a972e2e

File tree

1 file changed

+5
-1
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing

1 file changed

+5
-1
lines changed

bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/PDFDocument.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,11 @@ public void internal_dispose_GC(long hDC, GCData data) {
330330
NSAutoreleasePool pool = null;
331331
if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
332332
try {
333-
NSGraphicsContext.static_restoreGraphicsState();
333+
// Only restore the graphics state if it hasn't been restored yet by uncheckGC()
334+
if (data != null && data.restoreContext) {
335+
NSGraphicsContext.static_restoreGraphicsState();
336+
data.restoreContext = false;
337+
}
334338
if (data != null) isGCCreated = false;
335339
} finally {
336340
if (pool != null) pool.release();

0 commit comments

Comments
 (0)