This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 389442 - [Perspectives] Adding MPlaceholder to rendered but inactive MPerspective causes MPlaceholder in active MPerspective to lose its widget rendering
Summary: [Perspectives] Adding MPlaceholder to rendered but inactive MPerspective caus...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 4.4 M7   Edit
Assignee: Eric Moffatt CLA
QA Contact: Eric Moffatt CLA
URL:
Whiteboard: candidate43
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-12 14:37 EDT by Ben Roling CLA
Modified: 2014-05-01 10:02 EDT (History)
3 users (show)

See Also:


Attachments
Sample application demonstrating bug (12.15 KB, application/x-zip-compressed)
2012-09-12 14:39 EDT, Ben Roling CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Roling CLA 2012-09-12 14:37:25 EDT
I noticed this problem in an e4 RCP application I am working on.  If a part is referenced by a placeholder in a stack in the active perspective and you add a new placeholder (pointing to the same part) to another stack in another (inactive, but rendered) perspective, the part disappears from the active perspective.  The space and corresponding tab are still there but the part inside it disappears.

The reason this happens is because the renderer re-parents the top level Composite of the part to the CTabFolder of the stack in the inactive perspective.

I will attach a very simple sample application that demonstrates the issue.  The application has two perspectives.  To recreate the issue you launch the application (which opens the 1st perspective).  Then switch to the 2nd perspective and then back to the 1st perspective.  Finally, click a button in the 1st perspective that will programmatically create another MPlaceholder on the 2nd perspective referencing the part displayed in the 1st perspective.  At this point, the part will disappear.  If this bug were fixed, clicking the button would have no visible impact until the next time you switched to the 2nd perspective.
Comment 1 Ben Roling CLA 2012-09-12 14:39:59 EDT
Created attachment 220992 [details]
Sample application demonstrating bug
Comment 2 Ben Roling CLA 2012-09-12 14:41:30 EDT
I meant to note that I tested this behaviour in both 4.2 and 4.1.1.  The issue exists in both.
Comment 3 Eric Moffatt CLA 2012-09-24 11:38:42 EDT
Ben, good pickup. This is indeed an interesting problem...the current code is too simplistic; it assumes that adding elements to existing rendered UI's should cause them to appear.

Perhaps we should see if changing the logic to ensure that *parent* of the element being added is 'on top' (i.e. either it or its ancestors are all the 'selecedElement' of any intervening 'stack' containers... ? This would fix this case because the newly added element has an ancestor (its Perspective) that is *not* the selected element of the PerspectiveStack.
Comment 4 Ben Roling CLA 2012-09-27 11:23:14 EDT
Thanks for taking a look at this Eric.  Your suggested means of resolution sounds reasonable to me.
Comment 5 Eric Moffatt CLA 2014-02-28 14:13:59 EST
Committed:

http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=cd490a6d008f1daef7365677ba83cd78511fe41a

This ensures that rendering the new placeholder will *not* 'adopt' its referenced view unless the placeholder is in the currently active perspective.
Comment 6 Eric Moffatt CLA 2014-02-28 15:08:18 EST
Oops, commit in haste and repent at loss of leisure (i.e. I've reverted the fix due to issues with the Welcome handling and I'll try again over the weekend...;-).
Comment 7 Eric Moffatt CLA 2014-03-02 15:13:10 EST
OK I've pushed the original fix to gerrit far a look...

https://git.eclipse.org/r/22731

I've seen this fail once but can't repro...it doesn't seem to break anything so far...Ben could you check out the patch ?
Comment 8 Eric Moffatt CLA 2014-03-03 09:24:02 EST
I'll defer this to M7 since it's not API related...
Comment 9 Ben Roling CLA 2014-03-03 14:43:25 EST
(In reply to Eric Moffatt from comment #7)
> I've seen this fail once but can't repro...it doesn't seem to break anything
> so far...Ben could you check out the patch ?

I no longer work on the project I was working on where I was using RCP.  I will forward this to some colleagues who still do and see if they might take a look.  Sorry!
Comment 10 Eric Moffatt CLA 2014-03-05 13:47:19 EST
Committed:

http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=4aa8c6db1c9e235e1f3dccbc16450ceb63eccc5a

This causes the ElementReferenceRenderer to only 'adopt' the referenced element if it's in the currently active perspective.
Comment 11 Paul Webster CLA 2014-03-05 14:00:45 EST
We've reverted this fix and will look at it again in M7

Reverted with http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=6181cfea6e8683c138f18f6bc65ab35d33e9fa30

PW
Comment 12 Eric Moffatt CLA 2014-03-06 15:11:01 EST
For clarity, the issue surrounds a few of our automated tests in this area and not a known functional breakage of the code itself.
Comment 13 Paul Webster CLA 2014-03-27 10:59:54 EDT
Looking at fix https://git.eclipse.org/r/#/c/22731/

It caused a failure and 2 errors in the e4 tests:


UIAllTests-fixed
org.eclipse.e4.ui.tests.UIAllTests
org.eclipse.e4.ui.tests.workbench.PartRenderingEngineTests
testBug348215_PartPlaceholderContextReparent(org.eclipse.e4.ui.tests.workbench.PartRenderingEngineTests)
junit.framework.AssertionFailedError
	at junit.framework.Assert.fail(Assert.java:55)
	at junit.framework.Assert.assertTrue(Assert.java:22)
	at junit.framework.Assert.assertTrue(Assert.java:31)
	at junit.framework.TestCase.assertTrue(TestCase.java:201)
	at org.eclipse.e4.ui.tests.workbench.PartRenderingEngineTests.testBug348215_PartPlaceholderContextReparent(PartRenderingEngineTests.java:2797)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at junit.framework.TestCase.runTest(TestCase.java:176)
	at junit.framework.TestCase.runBare(TestCase.java:141)
	at junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit.framework.TestResult.run(TestResult.java:125)
	at junit.framework.TestCase.run(TestCase.java:129)
	at junit.framework.TestSuite.runTest(TestSuite.java:255)
	at junit.framework.TestSuite.run(TestSuite.java:250)
	at junit.framework.TestSuite.runTest(TestSuite.java:255)
	at junit.framework.TestSuite.run(TestSuite.java:250)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:131)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
	at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:379)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:233)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1462)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)

testBug348069_DetachedPerspectiveWindow_01_TRUE(org.eclipse.e4.ui.tests.workbench.PartRenderingEngineTests)
java.lang.NullPointerException
	at org.eclipse.e4.ui.tests.workbench.PartRenderingEngineTests.testBug348069_DetachedPerspectiveWindow_01(PartRenderingEngineTests.java:3104)
	at org.eclipse.e4.ui.tests.workbench.PartRenderingEngineTests.testBug348069_DetachedPerspectiveWindow_01_TRUE(PartRenderingEngineTests.java:3112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at junit.framework.TestCase.runTest(TestCase.java:176)
	at junit.framework.TestCase.runBare(TestCase.java:141)
	at junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit.framework.TestResult.run(TestResult.java:125)
	at junit.framework.TestCase.run(TestCase.java:129)
	at junit.framework.TestSuite.runTest(TestSuite.java:255)
	at junit.framework.TestSuite.run(TestSuite.java:250)
	at junit.framework.TestSuite.runTest(TestSuite.java:255)
	at junit.framework.TestSuite.run(TestSuite.java:250)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:131)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
	at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:379)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:233)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1462)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)

testBug348069_DetachedPerspectiveWindow_02_TRUE(org.eclipse.e4.ui.tests.workbench.PartRenderingEngineTests)
java.lang.NullPointerException
	at org.eclipse.e4.ui.tests.workbench.PartRenderingEngineTests.testBug348069_DetachedPerspectiveWindow_02(PartRenderingEngineTests.java:3170)
	at org.eclipse.e4.ui.tests.workbench.PartRenderingEngineTests.testBug348069_DetachedPerspectiveWindow_02_TRUE(PartRenderingEngineTests.java:3188)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at junit.framework.TestCase.runTest(TestCase.java:176)
	at junit.framework.TestCase.runBare(TestCase.java:141)
	at junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit.framework.TestResult.run(TestResult.java:125)
	at junit.framework.TestCase.run(TestCase.java:129)
	at junit.framework.TestSuite.runTest(TestSuite.java:255)
	at junit.framework.TestSuite.run(TestSuite.java:250)
	at junit.framework.TestSuite.runTest(TestSuite.java:255)
	at junit.framework.TestSuite.run(TestSuite.java:250)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:131)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
	at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:379)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:233)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1462)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Comment 14 Eric Moffatt CLA 2014-03-27 14:46:03 EDT
Paul, I've pushed a new change set to Gerrit. This one has the original fix as well as a fix to the EModelService#getElementLocation method that is more accurate than the original in that it correctly identifies an MWindow owned by another MWindow as being OUTSIDE_PERSPECTIVE rather than NOT_IN_UI (which is what apparently caused the test errors).
Comment 15 Paul Webster CLA 2014-04-02 15:03:42 EDT
The current patch still causes one failure:

UI Test Suite-fixed
org.eclipse.ui.tests.UiTestSuite
org.eclipse.ui.tests.api.ApiTestSuite
org.eclipse.ui.tests.api.IWorkbenchPageTest
testSetPartState(org.eclipse.ui.tests.api.IWorkbenchPageTest)
junit.framework.AssertionFailedError: A minimized view should be a fast view
	at junit.framework.Assert.fail(Assert.java:57)
	at junit.framework.Assert.assertTrue(Assert.java:22)
	at junit.framework.TestCase.assertTrue(TestCase.java:192)
	at org.eclipse.ui.tests.api.IWorkbenchPageTest.testSetPartState(IWorkbenchPageTest.java:3091)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


PW
Comment 16 Eric Moffatt CLA 2014-04-08 15:10:27 EDT
The test problem was a change in the logic of the 'getElementLocation' which used to only return *one* of IN_ACTIVE_PERSPECTIVE or IN_ANY_PERSPECTIVE to return both bits (braking the case statement in WorkbenchPage#getActiveElement).

I've pushed a new change to the existing Gerrit patch that restores the old logic and all tests are now green.
Comment 17 Paul Webster CLA 2014-04-08 15:36:18 EDT
(In reply to Paul Webster from comment #13)
> Looking at fix https://git.eclipse.org/r/#/c/22731/
>

Looks good now.  Released as http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=b0a13a0935caedd44f2c25afc1d1305edd81f177

PW
Comment 18 Eric Moffatt CLA 2014-05-01 10:02:06 EDT
Verified in 4.4.0.I20140501-0200.