summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Northover <steve>2005-08-03 20:05:21 +0000
committerSteve Northover <steve>2005-08-03 20:05:21 +0000
commitf508e585069cdbc0d3ee1180a1898e6e8297666e (patch)
treef9beb0eb0491ce60a17b19a14d1c862913ac5da8
parenta87010dff4f9eb0100e5770e5231c5d437c6da3f (diff)
downloadeclipse.platform.swt-f508e585069cdbc0d3ee1180a1898e6e8297666e.tar.gz
eclipse.platform.swt-f508e585069cdbc0d3ee1180a1898e6e8297666e.tar.xz
eclipse.platform.swt-f508e585069cdbc0d3ee1180a1898e6e8297666e.zip
45708 - NPE in Table.releaseWidget
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java41
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java31
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java14
5 files changed, 81 insertions, 35 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java
index e6237744fd..5aad1fb653 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java
@@ -76,6 +76,10 @@ public abstract class Widget {
/* A layout was requested in this widget hierachy */
static final int LAYOUT_CHILD = 1<<12;
+ /* More global state flags */
+ static final int RELEASED = 1<<13;
+
+ /* Default size for widgets */
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
@@ -605,8 +609,13 @@ public void dispose () {
* Note: It is valid to attempt to dispose a widget
* more than once. If this happens, fail silently.
*/
- if (isDisposed()) return;
+ if (isDisposed ()) return;
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if ((state & RELEASED) != 0) {
+ state |= DISPOSED;
+ return;
+ }
+ state |= RELEASED;
releaseChild ();
releaseWidget ();
destroyWidget ();
@@ -1290,12 +1299,15 @@ void releaseHandle () {
}
void releaseResources () {
+ if ((state & RELEASED) != 0) return;
+ state |= RELEASED;
releaseWidget ();
releaseHandle ();
}
void releaseWidget () {
sendEvent (SWT.Dispose);
+ state &= ~DISPOSED;
deregister ();
eventTable = null;
data = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
index e283c5db73..08a1db97d0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
@@ -60,15 +60,15 @@ public abstract class Widget {
Object data;
/* Global state flags */
- static final int DISPOSED = 1<<0;
- static final int CANVAS = 1<<1;
- static final int KEYED_DATA = 1<<2;
- static final int HANDLE = 1<<3;
- static final int DISABLED = 1<<4;
- static final int MENU = 1<<5;
- static final int OBSCURED = 1<<6;
- static final int MOVED = 1<<7;
- static final int RESIZED = 1<<8;
+ static final int DISPOSED = 1<<0;
+ static final int CANVAS = 1<<1;
+ static final int KEYED_DATA = 1<<2;
+ static final int HANDLE = 1<<3;
+ static final int DISABLED = 1<<4;
+ static final int MENU = 1<<5;
+ static final int OBSCURED = 1<<6;
+ static final int MOVED = 1<<7;
+ static final int RESIZED = 1<<8;
static final int ZERO_SIZED = 1<<9;
static final int HIDDEN = 1<<10;
static final int FOREGROUND = 1<<11;
@@ -83,8 +83,11 @@ public abstract class Widget {
/* A layout was requested in this widget hierachy */
static final int LAYOUT_CHILD = 1<<16;
+
+ /* More global state flags */
+ static final int RELEASED = 1<<17;
- /* Default widths for widgets */
+ /* Default size for widgets */
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
@@ -405,8 +408,13 @@ public void dispose () {
* Note: It is valid to attempt to dispose a widget
* more than once. If this happens, fail silently.
*/
- if (isDisposed()) return;
+ if (isDisposed ()) return;
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if ((state & RELEASED) != 0) {
+ state |= DISPOSED;
+ return;
+ }
+ state |= RELEASED;
releaseChild ();
releaseWidget ();
destroyWidget ();
@@ -813,8 +821,6 @@ char [] fixMnemonic (String string) {
* @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
*/
public boolean isDisposed () {
- if (handle != 0) return false;
- if ((state & HANDLE) != 0) return true;
return (state & DISPOSED) != 0;
}
@@ -840,12 +846,6 @@ boolean isValidThread () {
return getDisplay ().isValidThread ();
}
-boolean isValidWidget () {
- if (handle != 0) return true;
- if ((state & HANDLE) != 0) return false;
- return (state & DISPOSED) == 0;
-}
-
boolean isValidSubclass() {
return Display.isValidClass(getClass());
}
@@ -936,12 +936,15 @@ void releaseHandle () {
}
void releaseResources () {
+ if ((state & RELEASED) != 0) return;
+ state |= RELEASED;
releaseWidget ();
releaseHandle ();
}
void releaseWidget () {
sendEvent (SWT.Dispose);
+ state &= ~DISPOSED;
deregister ();
eventTable = null;
data = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java
index b076bfe599..849bb1bcce 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java
@@ -54,21 +54,24 @@ public abstract class Widget {
Object data;
/* Global state flags */
- static final int DISPOSED = 1<<0;
- static final int CANVAS = 1<<1;
- static final int KEYED_DATA = 1<<2;
- static final int HANDLE = 1<<3;
- static final int FOCUS_FORCED = 1<<4;
+ static final int DISPOSED = 1<<0;
+ static final int CANVAS = 1<<1;
+ static final int KEYED_DATA = 1<<2;
+ static final int FOCUS_FORCED = 1<<3;
/* A layout was requested on this widget */
- static final int LAYOUT_NEEDED = 1<<5;
+ static final int LAYOUT_NEEDED = 1<<4;
/* The preferred size of a child has changed */
- static final int LAYOUT_CHANGED = 1<<6;
+ static final int LAYOUT_CHANGED = 1<<5;
/* A layout was requested in this widget hierachy */
- static final int LAYOUT_CHILD = 1<<7;
+ static final int LAYOUT_CHILD = 1<<6;
+
+ /* More global state flags */
+ static final int RELEASED = 1<<7;
+ /* Default size for widgets */
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
@@ -334,8 +337,13 @@ public void dispose () {
* Note: It is valid to attempt to dispose a widget
* more than once. If this happens, fail silently.
*/
- if (isDisposed()) return;
+ if (isDisposed ()) return;
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if ((state & RELEASED) != 0) {
+ state |= DISPOSED;
+ return;
+ }
+ state |= RELEASED;
releaseChild ();
releaseWidget ();
destroyWidget ();
@@ -505,8 +513,6 @@ boolean hooks (int eventType) {
* @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
*/
public boolean isDisposed () {
- if (handle != 0) return false;
- if ((state & HANDLE) != 0) return true;
return (state & DISPOSED) != 0;
}
/**
@@ -623,11 +629,14 @@ void releaseHandle () {
display = null;
}
void releaseResources () {
+ if ((state & RELEASED) != 0) return;
+ state |= RELEASED;
releaseWidget ();
releaseHandle ();
}
void releaseWidget () {
sendEvent (SWT.Dispose);
+ state &= ~DISPOSED;
deregister ();
eventTable = null;
data = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
index f1cd6fa51c..2cb7763d0a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
@@ -77,9 +77,13 @@ public abstract class Widget {
/* A layout was requested in this widget hierachy */
static final int LAYOUT_CHILD = 1 << 10;
+
+ /* More global state flags */
+ static final int RELEASED = 1<<11;
+ /* Default size for widgets */
static final int DEFAULT_WIDTH = 64;
- static final int DEFAULT_HEIGHT = 64;
+ static final int DEFAULT_HEIGHT = 64;
Widget () {
/* Do nothing */
@@ -427,8 +431,13 @@ public void dispose () {
* Note: It is valid to attempt to dispose a widget
* more than once. If this happens, fail silently.
*/
- if (isDisposed()) return;
+ if (isDisposed ()) return;
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if ((state & RELEASED) != 0) {
+ state |= DISPOSED;
+ return;
+ }
+ state |= RELEASED;
releaseChild ();
releaseWidget ();
destroyWidget ();
@@ -772,12 +781,15 @@ void releaseHandle () {
}
void releaseResources () {
+ if ((state & RELEASED) != 0) return;
+ state |= RELEASED;
releaseWidget ();
releaseHandle ();
}
void releaseWidget () {
sendEvent (SWT.Dispose);
+ state &= ~DISPOSED;
deregister ();
eventTable = null;
data = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
index 5454a18b65..5347b073a7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
@@ -66,9 +66,11 @@ public abstract class Widget {
/* A layout was requested in this widget hierachy */
static final int LAYOUT_CHILD = 1<<7;
- static final int TRANSPARENT = 1<<8;
+ /* More global state flags */
+ static final int TRANSPARENT = 1<<8;
+ static final int RELEASED = 1<<9;
- /* Default widths for widgets */
+ /* Default size for widgets */
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
@@ -388,6 +390,11 @@ public void dispose () {
*/
if (isDisposed ()) return;
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if ((state & RELEASED) != 0) {
+ state |= DISPOSED;
+ return;
+ }
+ state |= RELEASED;
releaseChild ();
releaseWidget ();
destroyWidget ();
@@ -731,6 +738,8 @@ void releaseHandle () {
}
void releaseResources () {
+ if ((state & RELEASED) != 0) return;
+ state |= RELEASED;
releaseWidget ();
releaseHandle ();
}
@@ -767,6 +776,7 @@ void releaseResources () {
*/
void releaseWidget () {
sendEvent (SWT.Dispose);
+ state &= ~DISPOSED;
eventTable = null;
data = null;
}