diff options
author | Silenio Quarti <silenio> | 2005-10-25 20:03:45 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2005-10-25 20:03:45 +0000 |
commit | 498b1e35a8c935d42934ff8e43e776e87271b91d (patch) | |
tree | 4d9bdb29d7af244d2bfb3ea710a6529885705ebe | |
parent | 4a5479b6edb8a4ade9bed381a71082ad4e65f8a7 (diff) | |
download | eclipse.platform.swt-498b1e35a8c935d42934ff8e43e776e87271b91d.tar.gz eclipse.platform.swt-498b1e35a8c935d42934ff8e43e776e87271b91d.tar.xz eclipse.platform.swt-498b1e35a8c935d42934ff8e43e776e87271b91d.zip |
85069 & 100668 - segment fault on exit and SWT.Deactivate order
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java | 42 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java | 23 |
2 files changed, 54 insertions, 11 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java index d936a60929..f11ab40fa0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java @@ -121,6 +121,7 @@ public class Display extends Device { /* Deferred dispose window */ int disposeWindow; + int [] disposeWindowList; /* Sync/Async Widget Communication */ Synchronizer synchronizer = new Synchronizer (this); @@ -533,6 +534,25 @@ void addWidget (int handle, Widget widget) { widgetTable [oldSlot] = widget; } +void addDisposeWindow (int window) { + if (disposeWindowList == null) disposeWindowList = new int [4]; + int length = disposeWindowList.length; + for (int i=0; i<length; i++) { + if (disposeWindowList [i] == window) return; + } + int index = 0; + while (index < length) { + if (disposeWindowList [index] == 0) break; + index++; + } + if (index == length) { + int [] newList = new int [length + 4]; + System.arraycopy (disposeWindowList, 0, newList, 0, length); + disposeWindowList = newList; + } + disposeWindowList [index] = window; +} + /** * Causes the <code>run()</code> method of the runnable to * be invoked by the user-interface thread at the next @@ -1053,6 +1073,21 @@ int drawItemProc (int browser, int item, int property, int itemState, int theRec return OS.noErr; } +void disposeWindows () { + if (disposeWindow != 0) { + OS.DisposeWindow (disposeWindow); + disposeWindow = 0; + } + if (disposeWindowList != null) { + for (int i = 0; i < disposeWindowList.length; i++) { + if (disposeWindowList [i] != 0) { + OS.DisposeWindow (disposeWindowList [i]); + } + } + disposeWindowList = null; + } +} + void error (int code) { SWT.error(code); } @@ -2927,6 +2962,8 @@ protected void release () { } void releaseDisplay () { + disposeWindows (); + actionCallback.dispose (); appleEventCallback.dispose (); caretCallback.dispose (); @@ -3672,10 +3709,7 @@ void setMenuBar (Menu menu) { public boolean sleep () { checkDevice (); if (getMessageCount () != 0) return true; - if (disposeWindow != 0) { - OS.DisposeWindow (disposeWindow); - disposeWindow = 0; - } + disposeWindows (); if (eventTable != null && eventTable.hooks (SWT.Settings)) { RGBColor color = new RGBColor (); int status = OS.noErr, depth = getDepth (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java index aee175c51e..300fd683ad 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java @@ -104,7 +104,7 @@ import org.eclipse.swt.graphics.*; */ public class Shell extends Decorations { int shellHandle, windowGroup; - boolean resized, moved, drawing, reshape, update, activate, active, disposed, opened; + boolean resized, moved, drawing, reshape, update, deactivate, activate, active, disposed, opened; int invalRgn; Control lastActive; Region region; @@ -521,11 +521,20 @@ void destroyWidget () { * causes a segment fault when an application is exiting. This * seems to happen to large applications. The fix is to avoid * calling HideWindow() when a shell is about to be disposed. + * + * Bug in the Macintosh. Disposing a window from kEventWindowDeactivated + * causes a segment fault. The fix is to defer disposing the window until + * the event loop becomes idle. */ -// OS.HideWindow (shellHandle); + Display display = this.display; + if (deactivate) OS.HideWindow (shellHandle); releaseHandle (); if (theWindow != 0) { - OS.DisposeWindow (theWindow); + if (deactivate) { + display.addDisposeWindow (theWindow); + } else { + OS.DisposeWindow (theWindow); + } } } @@ -925,10 +934,10 @@ int kEventWindowDeactivated (int nextHandler, int theEvent, int userData) { int result = super.kEventWindowDeactivated (nextHandler, theEvent, userData); if (result == OS.noErr) return result; if (active) { + deactivate = true; active = false; - //TEMPORARY CODE - should be send, but causes a GP Display display = this.display; - postEvent (SWT.Deactivate); + sendEvent (SWT.Deactivate); if (isDisposed ()) return result; saveFocus (); if (savedFocus != null) { @@ -941,10 +950,10 @@ int kEventWindowDeactivated (int nextHandler, int theEvent, int userData) { display.ignoreFocus = true; OS.ClearKeyboardFocus (shellHandle); display.ignoreFocus = false; - //TEMPORARY CODE - should be send, but causes a GP - if (!savedFocus.isDisposed ()) savedFocus.sendFocusEvent (SWT.FocusOut, true); + if (!savedFocus.isDisposed ()) savedFocus.sendFocusEvent (SWT.FocusOut, false); } display.setMenuBar (null); + deactivate = false; } return result; } |