Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 417989

Summary: SWTException in CoolBarManager.update() on updating disposed CoolItem
Product: [RT] RAP Reporter: Yury <swimmer_86>
Component: JFaceAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: rsternberg
Version: 2.1   
Target Milestone: 2.2 M2   
Hardware: PC   
OS: All   
Whiteboard: sr212
Attachments:
Description Flags
stacktrace of calling CoolItem dispose by CoolBarManager.update
none
proposed patch
none
Proposed patch none

Description Yury CLA 2013-09-25 04:53:17 EDT
Created attachment 235799 [details]
stacktrace of calling CoolItem dispose by CoolBarManager.update

Discussion was started there - http://www.eclipse.org/forums/index.php/m/1116269/.

CoolBarManager on update method call toolbar resizing that leads to disposing some CoolItems by chain of resizing dew to listeners attached in org.eclipse.jface.action.CoolBarManager.addCoolBarResizeListener().

(CoolBarManager).update(boolean) line: 952 will throw SWTException when try to getData from disposed CoolItem.

Stacktrace of CoolItem disposing and proposed patch are attached.
Comment 1 Yury CLA 2013-09-25 04:53:56 EDT
Created attachment 235800 [details]
proposed patch
Comment 2 Ivan Furnadjiev CLA 2013-09-26 08:20:36 EDT
Created attachment 235847 [details]
Proposed patch

Yury, could you try the attached patch. I've introduced "inUpdate" filed which is used to skip the resize listener execution. When CoolBarManager#update() is called, the contribution items sizes are updated at the end of the method anyway.
Comment 3 Yury CLA 2013-09-27 00:15:33 EDT
Thank you, Ivan for the quick fix - this patch works.
It seems to me that resize listeners should not be notified when coolBar.setRedraw(false) is set.
See org.eclipse.jface.action.CoolBarManager.update(boolean)

...

try {
            coolBar.setRedraw(false);
            inUpdate = true;
...
} finally {
            coolBar.setRedraw(true);
            inUpdate = false;
        }

Your flag inUpdate is synchronized with need redraw state.
It is just my thoughts.

Is it possible to include these fixes in RAP 2.1.1?
Comment 4 Ivan Furnadjiev CLA 2013-09-27 03:29:10 EDT
Applied the patch to master with commit b76264fce735822d8e33ca7c60141d5bff9aa65b. The redraw flag does not affect control resizing (listeners) in SWT. It only suppresses the OS drawing operations on the control. Yury, it's too late for 2.1.1 - the 2.1.1 build will be available for download today. I will mark it for consideration for 2.1.2.
Comment 5 Ralf Sternberg CLA 2014-01-27 11:06:37 EST
+1 for backporting to 2.1.2
Comment 6 Ivan Furnadjiev CLA 2014-01-29 05:42:28 EST
Backported to 2.1-maintenance branch with change https://git.eclipse.org/r/21238.