Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Widget is disposed!!!
Widget is disposed!!! [message #458685] Tue, 19 July 2005 10:06 Go to next message
mohit is currently offline mohitFriend
Messages: 24
Registered: July 2009
Junior Member
Hi,
My application is throwing a "Widget is disposed" exception, when a tab is
closed and reopend again (using window->show view). The view object still
shows all the elements sitting on it, however, upon accessing their
various properties (like getText() etc.), it throws an SWTException caused
by "Widget is disposed".
I am attaching the complete stack trace. Any suggestion to get around this
are welcome.

Thanks,
Mohit

PS: one of the makeshift solution is to make the entire perspective fixed,
so that user can not close a tab. However, I m looking for a solution
wherein user should not feel restricted.
------------------------------------------------------------ -----------------
org.eclipse.swt.SWTException: Widget is disposed
at org.eclipse.swt.SWT.error(SWT.java:2940)
at org.eclipse.swt.SWT.error(SWT.java:2863)
at org.eclipse.swt.SWT.error(SWT.java:2834)
at org.eclipse.swt.widgets.Widget.error(Widget.java:393)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:295)
at org.eclipse.swt.widgets.Combo.getText(Combo.java:704)
at
com.qwest.rx.ottodesktop.views.WatchListView$WatchListModelL istener.notify(WatchListView.java:118)
at
com.qwest.rx.ottodesktop.DesktopManager.notifyListeners(Desk topManager.java:124)
at
com.qwest.rx.ottodesktop.DesktopManager.postEvent(DesktopMan ager.java:110)
at
com.qwest.rx.ottodesktop.views.WatchListView$5.widgetSelecte d(WatchListView.java:293)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:89)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:2921)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2554)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1601)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1565)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:315)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
at
com.qwest.rx.ottodesktop.PlatformRunnableImpl.run(PlatformRu nnableImpl.java:28)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:230)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:371)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:330 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:274)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Re: Widget is disposed!!! [message #458692 is a reply to message #458685] Tue, 19 July 2005 14:52 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
What are you doing when the tab is closed? If you are disposing the content
of the tab, then that would explain the widget is disposed error.

The content of the tab is a child of the TabFolder (or CTabFolder) and not a
child of the TabItem (or CTabItem). If you wish to reuse the widgets when
the tab is created again at a later time, rather than disposing the content,
just set the content to not be visible (setVisible(false)).

"Mohit" <mohit.jhawar@gmail.com> wrote in message
news:b5ac3592dd639d98834ab9ee3a3b3b27$1@www.eclipse.org...
> Hi,
> My application is throwing a "Widget is disposed" exception, when a tab is
> closed and reopend again (using window->show view). The view object still
> shows all the elements sitting on it, however, upon accessing their
> various properties (like getText() etc.), it throws an SWTException caused
> by "Widget is disposed".
> I am attaching the complete stack trace. Any suggestion to get around this
> are welcome.
>
> Thanks,
> Mohit
>
> PS: one of the makeshift solution is to make the entire perspective fixed,
> so that user can not close a tab. However, I m looking for a solution
> wherein user should not feel restricted.
> ------------------------------------------------------------ -----------------
> org.eclipse.swt.SWTException: Widget is disposed
> at org.eclipse.swt.SWT.error(SWT.java:2940)
> at org.eclipse.swt.SWT.error(SWT.java:2863)
> at org.eclipse.swt.SWT.error(SWT.java:2834)
> at org.eclipse.swt.widgets.Widget.error(Widget.java:393)
> at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:295)
> at org.eclipse.swt.widgets.Combo.getText(Combo.java:704)
> at
> com.qwest.rx.ottodesktop.views.WatchListView$WatchListModelL istener.notify(WatchListView.java:118)
> at
> com.qwest.rx.ottodesktop.DesktopManager.notifyListeners(Desk topManager.java:124)
> at
> com.qwest.rx.ottodesktop.DesktopManager.postEvent(DesktopMan ager.java:110)
> at
> com.qwest.rx.ottodesktop.views.WatchListView$5.widgetSelecte d(WatchListView.java:293)
> at
> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:89)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :82)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:2921)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2554)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1601)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1565)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:315)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
> at
> com.qwest.rx.ottodesktop.PlatformRunnableImpl.run(PlatformRu nnableImpl.java:28)
> at
> org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:230)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:371)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:160)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at org.eclipse.core.launcher.Main.invokeFramework(Main.java:330 )
> at org.eclipse.core.launcher.Main.basicRun(Main.java:274)
> at org.eclipse.core.launcher.Main.run(Main.java:977)
> at org.eclipse.core.launcher.Main.main(Main.java:952)
>
Re: Widget is disposed!!! [message #458698 is a reply to message #458692] Tue, 19 July 2005 15:33 Go to previous messageGo to next message
mohit is currently offline mohitFriend
Messages: 24
Registered: July 2009
Junior Member
Hi,
Sorry for querying in an obscure way. Here are the steps which caused the
exception.
1. Close a view tab using 'x' (one of the various views sitting on a
IFolderLayout)
2. open the view again using Window-> Show View
3. The selection listener of Combo (or any other element) post event to
some listener which is a inner class to the view class. (till this stage
the getText() of combo was returning some value and combo was alive)

Now, All the elements (Combo etc) when accessed from inner class of view
class indicate disposed status but are very much alive in the view class.

Inside the inner class my combo indicates disposed-off status and calling
getText() throws the SWTException.
------------------------------------------------------------ -----------------
public class WatchListView{

//listener to the view
class WatchListModelListener implements ModelUpdateListener{
public void notify(Event event) {

if(event.getEventId().equals(WatchListEvent.WATCHLIST_FETCH_ NAMES)){

WatchListView.this.populateWatchlistCombo(WatchListView.this .watchListType.getText());
}
}
}
------------------------------------------------------------ -----------------

I am not doing nything extra in dispose().


tia,
Mohit


Veronika Irvine wrote:

> What are you doing when the tab is closed? If you are disposing the content
> of the tab, then that would explain the widget is disposed error.

> The content of the tab is a child of the TabFolder (or CTabFolder) and not a
> child of the TabItem (or CTabItem). If you wish to reuse the widgets when
> the tab is created again at a later time, rather than disposing the content,
> just set the content to not be visible (setVisible(false)).

> "Mohit" <mohit.jhawar@gmail.com> wrote in message
> news:b5ac3592dd639d98834ab9ee3a3b3b27$1@www.eclipse.org...
>> Hi,
>> My application is throwing a "Widget is disposed" exception, when a tab is
>> closed and reopend again (using window->show view). The view object still
>> shows all the elements sitting on it, however, upon accessing their
>> various properties (like getText() etc.), it throws an SWTException caused
>> by "Widget is disposed".
>> I am attaching the complete stack trace. Any suggestion to get around this
>> are welcome.
>>
>> Thanks,
>> Mohit
>>
>> PS: one of the makeshift solution is to make the entire perspective fixed,
>> so that user can not close a tab. However, I m looking for a solution
>> wherein user should not feel restricted.
>>
------------------------------------------------------------ -----------------
>> org.eclipse.swt.SWTException: Widget is disposed
>> at org.eclipse.swt.SWT.error(SWT.java:2940)
>> at org.eclipse.swt.SWT.error(SWT.java:2863)
>> at org.eclipse.swt.SWT.error(SWT.java:2834)
>> at org.eclipse.swt.widgets.Widget.error(Widget.java:393)
>> at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:295)
>> at org.eclipse.swt.widgets.Combo.getText(Combo.java:704)
>> at
>>
com.qwest.rx.ottodesktop.views.WatchListView$WatchListModelL istener.notify(WatchListView.java:118)
>> at
>>
com.qwest.rx.ottodesktop.DesktopManager.notifyListeners(Desk topManager.java:124)
>> at
>> com.qwest.rx.ottodesktop.DesktopManager.postEvent(DesktopMan ager.java:110)
>> at
>>
com.qwest.rx.ottodesktop.views.WatchListView$5.widgetSelecte d(WatchListView.java:293)
>> at
>> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:89)
>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :82)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842)
>> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:2921)
>> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2554)
>> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1601)
>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1565)
>> at
>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:315)
>> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
>> at
>>
com.qwest.rx.ottodesktop.PlatformRunnableImpl.run(PlatformRu nnableImpl.java:28)
>> at
>>
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:230)
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:371)
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:160)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>> at
>>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:324)
>> at org.eclipse.core.launcher.Main.invokeFramework(Main.java:330 )
>> at org.eclipse.core.launcher.Main.basicRun(Main.java:274)
>> at org.eclipse.core.launcher.Main.run(Main.java:977)
>> at org.eclipse.core.launcher.Main.main(Main.java:952)
>>
Re: Widget is disposed!!! [message #458704 is a reply to message #458698] Tue, 19 July 2005 16:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Mohit" <mohit.jhawar@gmail.com> wrote in message
news:52c5d463354207bfdd171f62b63ec63e$1@www.eclipse.org...
> Hi,
> Sorry for querying in an obscure way. Here are the steps which caused the
> exception.
> 1. Close a view tab using 'x' (one of the various views sitting on a
> IFolderLayout)
> 2. open the view again using Window-> Show View
> 3. The selection listener of Combo (or any other element) post event to
> some listener which is a inner class to the view class. (till this stage
> the getText() of combo was returning some value and combo was alive)
>
> Now, All the elements (Combo etc) when accessed from inner class of view
> class indicate disposed status but are very much alive in the view class.
>
When you close (dispose) the view, make sure to remove the
watchListModelListener from the model.
What has happened is that even though the view was closed/disposed, the
listener object is still active and listening for model changes.
---
Sunil
Re: Widget is disposed!!! [message #458734 is a reply to message #458704] Wed, 20 July 2005 12:00 Go to previous message
mohit is currently offline mohitFriend
Messages: 24
Registered: July 2009
Junior Member
Thanks a lot Sunil.
I just forgot to unregister my listener :|

Thanks,
Mohit


Sunil Kamath wrote:

> "Mohit" <mohit.jhawar@gmail.com> wrote in message
> news:52c5d463354207bfdd171f62b63ec63e$1@www.eclipse.org...
>> Hi,
>> Sorry for querying in an obscure way. Here are the steps which caused the
>> exception.
>> 1. Close a view tab using 'x' (one of the various views sitting on a
>> IFolderLayout)
>> 2. open the view again using Window-> Show View
>> 3. The selection listener of Combo (or any other element) post event to
>> some listener which is a inner class to the view class. (till this stage
>> the getText() of combo was returning some value and combo was alive)
>>
>> Now, All the elements (Combo etc) when accessed from inner class of view
>> class indicate disposed status but are very much alive in the view class.
>>
> When you close (dispose) the view, make sure to remove the
> watchListModelListener from the model.
> What has happened is that even though the view was closed/disposed, the
> listener object is still active and listening for model changes.
> ---
> Sunil
Previous Topic:LabelProviders and Tree with columns
Next Topic:Real time updates in Virtual Table
Goto Forum:
  


Current Time: Tue Apr 23 17:46:27 GMT 2024

Powered by FUDForum. Page generated in 0.02765 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top