Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 65606 - [ViewMgmt] IPerspectiveListener2 is notified too late
Summary: [ViewMgmt] IPerspectiveListener2 is notified too late
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.0 RC3   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 62200
  Show dependency tree
 
Reported: 2004-06-03 15:26 EDT by Jared Burns CLA
Modified: 2004-06-16 20:09 EDT (History)
2 users (show)

See Also:


Attachments
Patch to fix the order (4.24 KB, patch)
2004-06-14 15:36 EDT, Nick Edgar CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jared Burns CLA 2004-06-03 15:26:33 EDT
When a view is hidden, the new IPerspectiveListener2 listeners are notified after dispose events 
have been received. This affects the DisplayView, which wants to persist its contents on closure. 
The events look like so:
1. IPartListener notified.
2. The ViewPane's DisposeListeners notified.
3. IPerspectiveListener2  notified.

This means that by the time IPerspectiveListener2 hears about the view being closed, important 
state can already be lost. In the case of the DisplayView, we have a TextListener which deletes its 
document in response to the dispose. This prevents us from accessing the view contents to persist 
them.

The code in question looks like it's in WorkbenchPage:

  private void hideView(Perspective persp, IViewReference ref) {
    // Hide the part.
    persp.hideView(ref);

    // Notify interested listeners
    window.firePerspectiveChanged(this, getPerspective(), ref, CHANGE_VIEW_HIDE);
    ...
  }

Would it make any sense to just reorder these lines?
Comment 1 Nick Edgar CLA 2004-06-04 10:44:27 EDT
Shouldn't the view's document only be disposed when the view is really closed,
not just closed in a perspective?  Why not just do this in DebugView's dispose()
method?
Comment 2 Jared Burns CLA 2004-06-04 11:35:19 EDT
There's no debug code involved in event 2. TextViewer (jface text) registers a DisposeListener (swt) on 
the Text widget when it's created. This listener is being called by UI/SWT before perspective listeners are 
notified (event #2).

TextViewer$1.widgetDisposed(DisposeEvent) line: 1357
TypedListener.handleEvent(Event) line: 100
EventTable.sendEvent(Event) line: 82
StyledText(Widget).sendEvent(Event) line: 944
StyledText(Widget).sendEvent(int, Event, boolean) line: 968
StyledText(Widget).sendEvent(int, Event) line: 953
StyledText(Widget).notifyListeners(int, Event) line: 823
StyledText.handleDispose(Event) line: 4877
StyledText$7.handleEvent(Event) line: 4748
EventTable.sendEvent(Event) line: 82
StyledText(Widget).sendEvent(Event) line: 944
StyledText(Widget).sendEvent(int, Event, boolean) line: 968
StyledText(Widget).sendEvent(int) line: 949
StyledText(Widget).releaseWidget() line: 855
StyledText(Control).releaseWidget() line: 2174
StyledText(Scrollable).releaseWidget() line: 259
StyledText(Composite).releaseWidget() line: 676
StyledText(Canvas).releaseWidget() line: 132
StyledText(Widget).releaseResources() line: 850
Composite.releaseChildren() line: 670
Composite.releaseWidget() line: 675
Composite(Widget).releaseResources() line: 850
Composite.releaseChildren() line: 670
Composite.releaseWidget() line: 675
Composite(Widget).dispose() line: 369
ViewPane(PartPane).dispose() line: 221
ViewPane.dispose() line: 254
ViewFactory.destroyView(IViewPart) line: 395
ViewFactory.releaseView(IViewReference) line: 479
Perspective.hideView(IViewReference) line: 465
WorkbenchPage.hideView(Perspective, IViewReference) line: 1829
WorkbenchPage.hideView(IViewPart) line: 1824
Comment 3 Michael Van Meekeren CLA 2004-06-14 13:47:08 EDT
Jared, are you still waiting on something here for R3.0?
Comment 4 Jared Burns CLA 2004-06-14 14:41:10 EDT
Yes. I'm using a patched version of the workbench (with the lines reordered) for the test pass.
Comment 5 Nick Edgar CLA 2004-06-14 15:36:52 EDT
Created attachment 12079 [details]
Patch to fix the order

This patch fixes the order of events so that the new listener is notified
before a view or editor is actually disposed.  Since this results in the new
listener being notifed before the old one when a part is closed, I've also
changed the order when a part is opened, for consistency.

Jared, can you please confirm that this fixes the problem for you?
Comment 6 Nick Edgar CLA 2004-06-14 16:40:00 EDT
Patch reviewed by MvM and released.
Comment 7 Jared Burns CLA 2004-06-14 17:26:07 EDT
woot! :)  (verified)
Comment 8 Nick Edgar CLA 2004-06-16 16:38:11 EDT
Jared, could you please verify this in one of the latest builds?
Comment 9 Jared Burns CLA 2004-06-16 19:37:16 EDT
Verified that the fix is in 200406161200.
Comment 10 Nick Edgar CLA 2004-06-16 20:09:51 EDT
Thanks.