Bug 301717 Renderer prematurely instantiates client objects when a part is added to a stack that's already showing another part
1. Have a window with a part stack that's showing a part. 2. Add another part to that stack without changing its selected element. 3. The new part's client object is prematurely instantiated. ------------ ### Eclipse Workspace Patch 1.0 #P org.eclipse.e4.ui.tests Index: src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java =================================================================== RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java,v retrieving revision 1.10 diff -u -r1.10 PartRenderingEngineTests.java --- src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java 3 Feb 2010 15:09:37 -0000 1.10 +++ src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java 3 Feb 2010 16:52:39 -0000 @@ -301,6 +323,8 @@ assertEquals( "Adding a part to a stack should not cause the stack's active child to change", partA, stack.getSelectedElement()); + assertNull("The object should not have been instantiated", partB + .getObject()); } public void testCreateGuiBug301021() throws Exception { ------------ Thread [main] (Suspended) SampleView.<init>(Composite, IEclipseContext, IExtensionRegistry) line: 45 NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not available [native method] NativeConstructorAccessorImpl.newInstance(Object[]) line: 67 DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 45 Constructor<T>.newInstance(Object...) line: 522 ContextInjector.callConstructor(Constructor, Object[]) line: 708 ContextInjector.make(Class) line: 590 Injector.make(Class) line: 48 ContextInjectionFactory.make(Class, IEclipseContext) line: 170 ReflectionContributionFactory.createFromBundle(Bundle, IEclipseContext, URI) line: 196 ReflectionContributionFactory.create(String, IEclipseContext) line: 172 ContributedPartRenderer.createWidget(MUIElement, Object) line: 87 PartRenderingEngine.createWidget(MUIElement, Object) line: 393 PartRenderingEngine.createGui(MUIElement, Object) line: 293 PartRenderingEngine.createGui(MUIElement) line: 355 PartRenderingEngine$2.handleEvent(Event) line: 125 UIEventHandler.handleEvent(Event) line: 41 EventHandlerWrapper.handleEvent(Event, Permission) line: 188 EventHandlerTracker.dispatchEvent(Object, Object, int, Object) line: 198 EventManager.dispatchEvent(Set, EventDispatcher, int, Object) line: 227 ListenerQueue.dispatchEventSynchronous(int, Object) line: 149 EventAdminImpl.dispatchEvent(Event, boolean) line: 139 EventAdminImpl.sendEvent(Event) line: 78 EventComponent.sendEvent(Event) line: 39 EventBroker.send(String, Object) line: 73 UIEventPublisher.notifyChanged(Notification) line: 58 PartStackImpl(BasicNotifierImpl).eNotify(Notification) line: 280 EObjectContainmentWithInverseEList<E>(EcoreEList<E>).dispatchNotification(Notification) line: 255 EObjectContainmentWithInverseEList<E>(NotifyingListImpl<E>).addUnique(E) line: 300 EObjectContainmentWithInverseEList<E>(AbstractEList<E>).add(E) line: 307 PartRenderingEngineTests.testPartStack_SetActiveChild6Bug295250() line: 321
bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/PartRenderingEngine.java
renderer.childRendered(changedElement, added);
				}
			} else if (UIEvents.EventTypes.REMOVE.equals(eventType)) {
				Activator.trace(Policy.DEBUG_RENDERER, "Child Removed", null); 
				MUIElement removed = (MUIElement) event
						.getProperty(UIEvents.EventTags.OLD_VALUE);
				
				
				if (!removed.isToBeRendered())
					return;
				if (renderer != null)
					renderer.hideChild(changedElement, removed);
			}
		}
	};
	private IEclipseContext appContext;
	protected Shell testShell;
	protected MApplication theApp;
	public PartRenderingEngine() {
	}
	public PartRenderingEngine(String curFactoryId) {
		this.curFactoryId = curFactoryId;
	}
	/**
	 * Initialize a part renderer from the extension point.
	 * 
	 * @param registry
	 *            the registry for the EP
	 * @param r
	 *            the created renderer