Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » SWTException in CoolBarManager on disposed CoolItem
SWTException in CoolBarManager on disposed CoolItem [message #1115475] Tue, 24 September 2013 06:46 Go to next message
Yury Mising name is currently offline Yury Mising nameFriend
Messages: 95
Registered: May 2010
Location: Russia
Member
We've got SWTException in our application based on RAP 2.1.
There are several coolItems iterated in CoolBarManager2
(CoolBarManager).update(boolean) line: 952
and updated.
During update the one of the iterated CoolItems is disposed and when the iterator will be on it - the SWTException thrown on getData method:
// Retrieve the corresponding contribution item from SWT's
                // data.
                if (sourceIndex < coolItems.length) {
                    destinationItem = (IContributionItem) coolItems[sourceIndex]
                            .getData();
                } else {
                    destinationItem = null;
                }


Here is the stack of the CoolItem disposing.
	CoolItem.dispose() line: 281	
	ToolBarContributionItem2(ToolBarContributionItem).updateSize(boolean) line: 639	
	ToolBarContributionItem2(ToolBarContributionItem).update(String) line: 595	
	CoolBarManager$1.controlResized(ControlEvent) line: 267	
	TypedListener.handleEvent(Event) line: 256	
	EventTable.sendEvent(Event) line: 85	
	CoolBar(Widget).sendEvent(Event) line: 700	
	CoolBar(Widget).notifyListeners(int, Event) line: 602	
	CoolBar(Control).notifyResize(Point) line: 2416	
	CoolBar(Composite).notifyResize(Point) line: 882	
	CoolBar(Control).setBounds(Rectangle, boolean) line: 2401	
	CoolBar(Control).setBounds(Rectangle) line: 855	
	CoolBar(Control).setSize(Point) line: 969	
	CoolBar(Control).setSize(int, int) line: 989	
	CoolBar.relayout() line: 1025	
	CoolBar.destroyItem(CoolItem) line: 537	
	CoolItem.dispose() line: 288	
	ToolBarContributionItem2(ToolBarContributionItem).updateSize(boolean) line: 639	
	ToolBarContributionItem2(ToolBarContributionItem).update(String) line: 595	
	CoolBarManager$1.controlResized(ControlEvent) line: 267	
	TypedListener.handleEvent(Event) line: 256	
	EventTable.sendEvent(Event) line: 85	
	CoolBar(Widget).sendEvent(Event) line: 700	
	CoolBar(Widget).notifyListeners(int, Event) line: 602	
	CoolBar(Control).notifyResize(Point) line: 2416	
	CoolBar(Composite).notifyResize(Point) line: 882	
	CoolBar(Control).setBounds(Rectangle, boolean) line: 2401	
	CoolBar(Control).setBounds(Rectangle) line: 855	
	CoolBar(Control).setSize(Point) line: 969	
	CoolBar(Control).setSize(int, int) line: 989	
	CoolBar.relayout() line: 1025	
	CoolItem.setSize(int, int) line: 724	
	CoolItem.setSize(Point) line: 753	
	ToolBarContributionItem2(ToolBarContributionItem).updateSize(boolean) line: 662	
	ToolBarContributionItem2(ToolBarContributionItem).fill(CoolBar, int) line: 251	
	CoolBarManager2(CoolBarManager).update(boolean) line: 952	
	SubCoolBarManager.update(boolean) line: 99	
	VisualReportViewerContributor(AbstractPageEditorContributor).updateBars() line: 481	
	VisualReportViewerContributor(AbstractPageEditorContributor).updateActiveContributor() line: 445	
	VisualReportViewerContributor(AbstractPageEditorContributor).setActivePage(IEditorPart) line: 179	
	VisualReportViewerContributor(MultiPageEditorActionBarContributor).setActiveEditor(IEditorPart) line: 51	
	VisualReportViewerContributor(AbstractPageEditorContributor).setActiveEditor(IEditorPart) line: 102	
	EditorActionBars.partChanged(IWorkbenchPart) line: 343	
	WorkbenchPage$3.run() line: 638	
	SafeRunner.run(ISafeRunnable) line: 42	
	Platform.run(ISafeRunnable) line: 854	
	WorkbenchPage.activatePart(IWorkbenchPart) line: 627	
	WorkbenchPage.setActivePart(IWorkbenchPart, boolean) line: 3527	
	WorkbenchPage.internalActivate(IWorkbenchPart, boolean) line: 620	
	WorkbenchPage.activate(IWorkbenchPart) line: 592	
	WorkbenchPage.busyOpenEditorBatched(IEditorInput, String, boolean, int, IMemento) line: 2870	
	WorkbenchPage.busyOpenEditor(IEditorInput, String, boolean, int, IMemento) line: 2763	
	WorkbenchPage.access$11(WorkbenchPage, IEditorInput, String, boolean, int, IMemento) line: 2755	
	WorkbenchPage$10.run() line: 2706	
	BusyIndicator.showWhile(Display, Runnable) line: 66	
	WorkbenchPage.openEditor(IEditorInput, String, boolean, int, IMemento) line: 2702	
	WorkbenchPage.openEditor(IEditorInput, String, boolean, int) line: 2686	
	IDE.openEditor(IWorkbenchPage, IEditorInput, String, boolean, int) line: 209	
	IDE.openEditor(IWorkbenchPage, IEditorInput, String, int) line: 126	
	IDE.openEditor(IWorkbenchPage, IEditorInput, String) line: 95	
	RAPDocumentService(DocumentService).internalOpenEditor(IDocument, Map, boolean) line: 711	
	DocumentService.access$8(DocumentService, IDocument, Map, boolean) line: 665	
	DocumentService$1.run() line: 550	
	RunnableLock.run() line: 38	
	UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 180	
	Display.runPendingMessages() line: 1189	
	Display.safeReadAndDispatch() line: 1169	
	Display.readAndDispatch() line: 1161	
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2733	
	Workbench.runUI() line: 2694	
	Workbench.access$5(Workbench) line: 2530	
	Workbench$5.run() line: 701	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 684	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 157	
	BiAdminEntryPoint.createUI(Display) line: 56	
	BiAdminEntryPoint(BaseEntryPoint).createUI() line: 160	
	RWTLifeCycle.createUI() line: 186	
	RWTLifeCycle$UIThreadController.run() line: 298	
	UIThread(Thread).run() line: 619	
	UIThread.run() line: 104


Removing the org.eclipse.jface.action.CoolBarManager.addCoolBarResizeListener() method solves the p[roblem, but it seems to me not a cause and solution.

Can you provide some thoughts about this and, probably, confirm a bug?

Best regards,
Yury.
Re: SWTException in CoolBarManager on disposed CoolItem [message #1115499 is a reply to message #1115475] Tue, 24 September 2013 07:22 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 1853
Registered: July 2009
Senior Member
Hi Yury,
the coolbar resize listener is RAP specific code (workaround for text
size determination issues) and it's probably a bug in RAP.
If item is disposed the call
....
coolItems = coolBar.getItems(); (line 907)
....
should not return it. For me it sounds like a bug in CoolItem disposal code.
Could you investigate why CoolBar#getItems() returns disposed items?
Also please open a bugzilla with a snippet to reproduce the issue.
Thanks,
Ivan

On 9/24/2013 9:46 AM, Yury Mising name wrote:
> We've got SWTException in our application based on RAP 2.1.
> There are several coolItems iterated in CoolBarManager2
> (CoolBarManager).update(boolean) line: 952
> and updated.
> During update the one of the iterated CoolItems is disposed and when
> the iterator will be on it - the SWTException thrown on getData method:
>
> // Retrieve the corresponding contribution item from SWT's
> // data.
> if (sourceIndex < coolItems.length) {
> destinationItem = (IContributionItem)
> coolItems[sourceIndex]
> .getData();
> } else {
> destinationItem = null;
> }
>
>
> Here is the stack of the CoolItem disposing.
>
> CoolItem.dispose() line: 281
> ToolBarContributionItem2(ToolBarContributionItem).updateSize(boolean)
> line: 639
> ToolBarContributionItem2(ToolBarContributionItem).update(String)
> line: 595
> CoolBarManager$1.controlResized(ControlEvent) line: 267
> TypedListener.handleEvent(Event) line: 256
> EventTable.sendEvent(Event) line: 85
> CoolBar(Widget).sendEvent(Event) line: 700
> CoolBar(Widget).notifyListeners(int, Event) line: 602
> CoolBar(Control).notifyResize(Point) line: 2416
> CoolBar(Composite).notifyResize(Point) line: 882
> CoolBar(Control).setBounds(Rectangle, boolean) line: 2401
> CoolBar(Control).setBounds(Rectangle) line: 855
> CoolBar(Control).setSize(Point) line: 969
> CoolBar(Control).setSize(int, int) line: 989
> CoolBar.relayout() line: 1025
> CoolBar.destroyItem(CoolItem) line: 537
> CoolItem.dispose() line: 288
> ToolBarContributionItem2(ToolBarContributionItem).updateSize(boolean)
> line: 639
> ToolBarContributionItem2(ToolBarContributionItem).update(String)
> line: 595
> CoolBarManager$1.controlResized(ControlEvent) line: 267
> TypedListener.handleEvent(Event) line: 256
> EventTable.sendEvent(Event) line: 85
> CoolBar(Widget).sendEvent(Event) line: 700
> CoolBar(Widget).notifyListeners(int, Event) line: 602
> CoolBar(Control).notifyResize(Point) line: 2416
> CoolBar(Composite).notifyResize(Point) line: 882
> CoolBar(Control).setBounds(Rectangle, boolean) line: 2401
> CoolBar(Control).setBounds(Rectangle) line: 855
> CoolBar(Control).setSize(Point) line: 969
> CoolBar(Control).setSize(int, int) line: 989
> CoolBar.relayout() line: 1025
> CoolItem.setSize(int, int) line: 724
> CoolItem.setSize(Point) line: 753
> ToolBarContributionItem2(ToolBarContributionItem).updateSize(boolean)
> line: 662
> ToolBarContributionItem2(ToolBarContributionItem).fill(CoolBar,
> int) line: 251
> CoolBarManager2(CoolBarManager).update(boolean) line: 952
> SubCoolBarManager.update(boolean) line: 99
> VisualReportViewerContributor(AbstractPageEditorContributor).updateBars()
> line: 481
> VisualReportViewerContributor(AbstractPageEditorContributor).updateActiveContributor()
> line: 445
> VisualReportViewerContributor(AbstractPageEditorContributor).setActivePage(IEditorPart)
> line: 179
> VisualReportViewerContributor(MultiPageEditorActionBarContributor).setActiveEditor(IEditorPart)
> line: 51
> VisualReportViewerContributor(AbstractPageEditorContributor).setActiveEditor(IEditorPart)
> line: 102
> EditorActionBars.partChanged(IWorkbenchPart) line: 343
> WorkbenchPage$3.run() line: 638
> SafeRunner.run(ISafeRunnable) line: 42
> Platform.run(ISafeRunnable) line: 854
> WorkbenchPage.activatePart(IWorkbenchPart) line: 627
> WorkbenchPage.setActivePart(IWorkbenchPart, boolean) line: 3527
> WorkbenchPage.internalActivate(IWorkbenchPart, boolean) line: 620
> WorkbenchPage.activate(IWorkbenchPart) line: 592
> WorkbenchPage.busyOpenEditorBatched(IEditorInput, String, boolean,
> int, IMemento) line: 2870
> WorkbenchPage.busyOpenEditor(IEditorInput, String, boolean, int,
> IMemento) line: 2763
> WorkbenchPage.access$11(WorkbenchPage, IEditorInput, String,
> boolean, int, IMemento) line: 2755
> WorkbenchPage$10.run() line: 2706
> BusyIndicator.showWhile(Display, Runnable) line: 66
> WorkbenchPage.openEditor(IEditorInput, String, boolean, int,
> IMemento) line: 2702
> WorkbenchPage.openEditor(IEditorInput, String, boolean, int) line:
> 2686
> IDE.openEditor(IWorkbenchPage, IEditorInput, String, boolean, int)
> line: 209
> IDE.openEditor(IWorkbenchPage, IEditorInput, String, int) line: 126
> IDE.openEditor(IWorkbenchPage, IEditorInput, String) line: 95
> RAPDocumentService(DocumentService).internalOpenEditor(IDocument,
> Map, boolean) line: 711
> DocumentService.access$8(DocumentService, IDocument, Map, boolean)
> line: 665
> DocumentService$1.run() line: 550
> RunnableLock.run() line: 38
> UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 180
> Display.runPendingMessages() line: 1189
> Display.safeReadAndDispatch() line: 1169
> Display.readAndDispatch() line: 1161
> Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2733
> Workbench.runUI() line: 2694
> Workbench.access$5(Workbench) line: 2530
> Workbench$5.run() line: 701
> Realm.runWithDefault(Realm, Runnable) line: 332
> Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 684
> PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 157
> BiAdminEntryPoint.createUI(Display) line: 56
> BiAdminEntryPoint(BaseEntryPoint).createUI() line: 160
> RWTLifeCycle.createUI() line: 186
> RWTLifeCycle$UIThreadController.run() line: 298
> UIThread(Thread).run() line: 619
> UIThread.run() line: 104
>
>
> Removing the
> org.eclipse.jface.action.CoolBarManager.addCoolBarResizeListener()
> method solves the p[roblem, but it seems to me not a cause and solution.
>
> Can you provide some thoughts about this and, probably, confirm a bug?
>
> Best regards,
> Yury.

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: SWTException in CoolBarManager on disposed CoolItem [message #1115539 is a reply to message #1115499] Tue, 24 September 2013 08:27 Go to previous messageGo to next message
Yury Mising name is currently offline Yury Mising nameFriend
Messages: 95
Registered: May 2010
Location: Russia
Member
Hello, Ivan!

First of all, Thank you for quick response!

coolItems = coolBar.getItems(); (line 907)

Does not return disposed item - it will be disposed later in
sourceItem.fill(coolBar, destinationIndex);
by calling relayout, size changing and listeners calling - where the CoolItem from coolBar.getItems() collection will be disposed (note that it will be disposed twice, see org.eclipse.swt.widgets.CoolItem.dispose()
 public void dispose() {
    if ( isDisposed() )
      return;

    /*
     * Must call parent.destroyItem() before super.dispose(), since it needs to
     * query the bounds to properly remove the item.
     */
    parent.destroyItem( this ); <-- calling this before super.dispose() leads to calling CoolItem.dispose again
    super.dispose();
    parent = null;
    control = null;

    /*
     * Although the parent for the chevron is the CoolBar (CoolItem can not be
     * the parent) it has to be disposed with the item
     */
    if ( chevron != null && !chevron.isDisposed() )
      chevron.dispose();
    chevron = null;
    if (arrowImage != null && !arrowImage.isDisposed()) arrowImage.dispose();
    arrowImage = null;

  }


It is not pretty simple to create a snippet, that is why I'm asking here for help Smile

Best regards,
Yury.
Re: SWTException in CoolBarManager on disposed CoolItem [message #1115629 is a reply to message #1115539] Tue, 24 September 2013 11:02 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 1853
Registered: July 2009
Senior Member
Hi Yury,
do you have a proposal for a fix without removing the coolbar resize
listener?
Best,
Ivan

On 9/24/2013 11:27 AM, Yury Mising name wrote:
> Hello, Ivan!
>
> First of all, Thank you for quick response!
>
> coolItems = coolBar.getItems(); (line 907)
>
> Does not return disposed item - it will be disposed later in
> sourceItem.fill(coolBar, destinationIndex);
> by calling relayout, size changing and listeners calling - where the
> CoolItem from coolBar.getItems() collection will be disposed (note
> that it will be disposed twice, see
> org.eclipse.swt.widgets.CoolItem.dispose()
>
> public void dispose() {
> if ( isDisposed() )
> return;
>
> /*
> * Must call parent.destroyItem() before super.dispose(), since it
> needs to
> * query the bounds to properly remove the item.
> */
> parent.destroyItem( this ); <-- calling this before super.dispose()
> leads to calling CoolItem.dispose again
> super.dispose();
> parent = null;
> control = null;
>
> /*
> * Although the parent for the chevron is the CoolBar (CoolItem can
> not be
> * the parent) it has to be disposed with the item
> */
> if ( chevron != null && !chevron.isDisposed() )
> chevron.dispose();
> chevron = null;
> if (arrowImage != null && !arrowImage.isDisposed())
> arrowImage.dispose();
> arrowImage = null;
>
> }
>
>
> It is not pretty simple to create a snippet, that is why I'm asking
> here for help :)
>
> Best regards,
> Yury.
>

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: SWTException in CoolBarManager on disposed CoolItem [message #1116269 is a reply to message #1115629] Wed, 25 September 2013 07:11 Go to previous messageGo to next message
Yury Mising name is currently offline Yury Mising nameFriend
Messages: 95
Registered: May 2010
Location: Russia
Member
Hello, Ivan.

The rough patch which fix the problem without removing listeners - additional checking iterated CoolItem on disposed state:

diff --git a/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/action/CoolBarManager.java b/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/action/CoolBarManager.java
old mode 100755
new mode 100644
index 1f8e297..a2537c3
--- a/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/action/CoolBarManager.java
+++ b/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/action/CoolBarManager.java
@@ -915,7 +915,7 @@
 
                 // Retrieve the corresponding contribution item from SWT's
                 // data.
-                if (sourceIndex < coolItems.length) {
+                if (sourceIndex < coolItems.length && !coolItems[sourceIndex].isDisposed()) {
                     destinationItem = (IContributionItem) coolItems[sourceIndex]
                             .getData();
                 } else {

In this case the SWTExcpetion will not thrown on getData().

Best regards,
Yury.
Re: SWTException in CoolBarManager on disposed CoolItem [message #1116280 is a reply to message #1116269] Wed, 25 September 2013 07:26 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 1853
Registered: July 2009
Senior Member
Hi Yury,
please open a bugzilla and attach the patch there.
Thanks,
Ivan

On 9/25/2013 10:11 AM, Yury Mising name wrote:
> Hello, Ivan.
>
> The rough patch which fix the problem without removing listeners -
> additional checking iterated CoolItem on disposed state:
>
>
> diff --git
> a/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/action/CoolBarManager.java
> b/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/action/CoolBarManager.java
>
> old mode 100755
> new mode 100644
> index 1f8e297..a2537c3
> ---
> a/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/action/CoolBarManager.java
> +++
> b/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/action/CoolBarManager.java
> @@ -915,7 +915,7 @@
>
> // Retrieve the corresponding contribution item from
> SWT's
> // data.
> - if (sourceIndex < coolItems.length) {
> + if (sourceIndex < coolItems.length &&
> !coolItems[sourceIndex].isDisposed()) {
> destinationItem = (IContributionItem)
> coolItems[sourceIndex]
> .getData();
> } else {
>
> In this case the SWTExcpetion will not thrown on getData().
>
> Best regards,
> Yury.

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: SWTException in CoolBarManager on disposed CoolItem [message #1116327 is a reply to message #1116280] Wed, 25 September 2013 08:54 Go to previous message
Yury Mising name is currently offline Yury Mising nameFriend
Messages: 95
Registered: May 2010
Location: Russia
Member
Done - https://bugs.eclipse.org/bugs/show_bug.cgi?id=417989
Previous Topic:Can I ensure that third party code uses my configured SettngStore
Next Topic:How to do a Synchronous call to custom widgets java backend
Goto Forum:
  


Current Time: Mon Nov 24 00:20:40 GMT 2014

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

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