Community
Participate
Working Groups
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?
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?
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
Jared, are you still waiting on something here for R3.0?
Yes. I'm using a patched version of the workbench (with the lines reordered) for the test pass.
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?
Patch reviewed by MvM and released.
woot! :) (verified)
Jared, could you please verify this in one of the latest builds?
Verified that the fix is in 200406161200.
Thanks.