Community
Participate
Working Groups
Created attachment 255897 [details] Example app PartServiceImpl.switchPerspective() fails to activate part when active view was docked into editors area. Exception is thrown: java.lang.NullPointerException at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.switchPerspective(PartServiceImpl.java:590) at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer.showTab(PerspectiveStackRenderer.java:127) ... Steps to reproduce: 1. Launch example app from attachment. 2. Drag&Drop Message view to editors area (area below view). 3. Switch perspective. 4. Activate Message view. 5. Switch perspective to previous one. 6. Activate Message view. 7. Switch perspective. Result: NPE in log.
Created attachment 255898 [details] Log with stacktrace
Created attachment 255954 [details] null check patch fixes NullPointerException by adding null check
In can see two possible causes of NPE in this scenario: 1) partActivationHistory.isValid(perspective, activePart) in PartServiceImpl#switchPerspective(MPerspective) returns false for part which was moved to editors area. It is because part's placeholder is hidden (toBeRendered = false) during perspective switch in method WorkbenchPage.setPerspective(IPerspectiveDescriptor) by line modelService.hideLocalPlaceholders(window, modelPerspective). #hideLocalPlaceholders() iterates through all placeholders and hide local placeholder that have global counterpart. In case of example app Message view has both local and global placeholders, local is original added in PerspectiveFactory and global is in editors area added when view was moved to editors area. I'm wondering if it is expected behaviour or #isValid() should return true in this case? 2) newActivePart.getParent() returns null because it's parent is TrimmedWindowImpl, and it does not pass below check: if (eContainerFeatureID() != UiPackageImpl.UI_ELEMENT__PARENT) return null; Here question is: is view moved into editors area has correct parent in application model? Please, advise where workflow goes wrong? If both suggestions are incorrect and it works as expected then NPE may be fixed by null check (patch attached).
I came across this bug report from the following AERI problem report: https://dev.eclipse.org/recommenders/committers/aeri/v2/#!/problems/5836b555e4b0a95537a8eeca Although I'm unable to reproduce this with Yuri's steps in 4.7, we're continuing to get reports in AERI and Yuri's fix is the same that I had put together, and looks safe.
New Gerrit change created: https://git.eclipse.org/r/100739
Gerrit change https://git.eclipse.org/r/100739 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=a2318aea7aeb731a6b1cadf0e85dd1e1287f4dd1
New Gerrit change created: https://git.eclipse.org/r/102824
Gerrit change https://git.eclipse.org/r/102824 was merged to [R4_7_maintenance]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=0f0bf80b1681ca2bdc8babe1926b22af0c2bcd87
Fixed in 4.7.1.
(In reply to Brian de Alwis from comment #9) > Fixed in 4.7.1. Next time, please make sure to check whether the bundle version needs to be increased. Thanks.
Verified by inspection in source.