From 837c55e190c8e5cbc4ae265a57764a38a907a7c9 Mon Sep 17 00:00:00 2001 From: Thomas Singer Date: Tue, 28 Nov 2023 12:53:12 +0100 Subject: [PATCH] Control: when disposing/releasing a control, check whether the set font is still alive --- .../cocoa/org/eclipse/swt/widgets/Control.java | 8 ++++++++ .../Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java | 8 ++++++++ .../win32/org/eclipse/swt/widgets/Control.java | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java index 13e26aa318e..8395a2578d5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java @@ -2941,6 +2941,14 @@ void release (boolean destroy) { } } +@Override +void releaseChildren (boolean destroy) { + if (font != null && font.isDisposed()) { + SWT.error(SWT.ERROR_GRAPHIC_DISPOSED, font.disposeStackTrace); + } + super.releaseChildren(destroy); +} + @Override void releaseHandle () { super.releaseHandle (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java index cd035eeef94..a380b8cb1a3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java @@ -4756,6 +4756,14 @@ void release (boolean destroy) { } } +@Override +void releaseChildren (boolean destroy) { + if (font != null && font.isDisposed()) { + SWT.error(SWT.ERROR_GRAPHIC_DISPOSED, font.disposeStackTrace); + } + super.releaseChildren(destroy); +} + @Override void releaseHandle () { super.releaseHandle (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java index 832b5cee72e..c68b1edc95e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java @@ -2468,6 +2468,14 @@ void register () { display.addControl (handle, this); } +@Override +void releaseChildren (boolean destroy) { + if (font != null && font.isDisposed()) { + SWT.error(SWT.ERROR_GRAPHIC_DISPOSED, font.disposeStackTrace); + } + super.releaseChildren(destroy); +} + @Override void releaseHandle () { super.releaseHandle ();