Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332876 - NPE in SashLayout.adjustWeights() when re-opening a closed window
Summary: NPE in SashLayout.adjustWeights() when re-opening a closed window
Status: RESOLVED WORKSFORME
Alias: None
Product: e4
Classification: Eclipse Project
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-17 18:41 EST by Brian de Alwis CLA
Modified: 2019-06-05 07:35 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian de Alwis CLA 2010-12-17 18:41:35 EST
Build: 4.1M4

On a Windows 7 machine, having closed a TrimmedWindow (through the window manager), I then try to reopen the window with:

	@Inject @Optional IPresentationEngine engine;
	
	public MWindow open(MApplication app, MWindow window) {
		window.setToBeRendered(true);
		window.setVisible(true);
		app.setSelectedElement(window);
		if(window.getRenderer() == null && engine != null) { 
			engine.createGui(window); 
		}
		app.setSelectedElement(window);
		return window;
         }

But what was the previously active perspective no longer renders -- it's just a blank canvas.  The perspective is a simple PartSashContainer with some parts.  The sash locations are still draggable, though there's nothing visible.  Dragging the sash throws an NPE as the leftRect is null.  Interestingly, the rightRect is not null.

Thread [main] (Suspended (exception NullPointerException))	
	SashLayout.adjustWeights(List<SashRect>, int, int) line: 170	
	SashLayout$2.mouseMove(MouseEvent) line: 88	
	TypedListener.handleEvent(Event) line: 205	
	EventTable.sendEvent(Event) line: 84	
	Composite(Widget).sendEvent(Event) line: 1053	
	Display.runDeferredEvents() line: 4084	
	Display.readAndDispatch() line: 3675	
	PartRenderingEngine$6.run() line: 808	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 724	
	E4Workbench.createAndRunUI(MApplicationElement) line: 89	
	E4Application.start(IApplicationContext) line: 131	
	Application.start(IApplicationContext) line: 62	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 369	
	EclipseStarter.run(String[], Runnable) line: 179	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available	
	Method.invoke(Object, Object...) line: not available	
	Main.invokeFramework(String[], URL[]) line: 622	
	Main.basicRun(String[]) line: 577	
	Main.run(String[]) line: 1410
Comment 1 Thomas CLA 2014-08-22 10:19:14 EDT
Similar problem;
reopen a closed MUIElement opens the window/Dialog bug don't repaint the parts.
windows.getChildren() still contains the partStack and the parts
Comment 2 Thomas CLA 2014-08-22 10:37:37 EDT
partially workaround:
close the window with a button 

MWindow window
...
btnExit.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				window.setToBeRendered(false);
			}
		});

reopen it:

@Execute
public static void execute(final MApplication application,
		final EModelService ms) {
	MUIElement e = ms.find("...yourWindowID",application);
	e.setToBeRendered(true);
	e.setOnTop(true);
}

unfortunately, if the user closes the window with Alt-F4 or the close-Button from the window, the problem remains.
To hide the window-close-Button you had to override the renderer. Heard this wouldn't be very complex.
Comment 3 Eclipse Genie CLA 2018-12-24 19:36:08 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Lars Vogel CLA 2019-06-05 07:35:44 EDT
This is a mass change to close all e4 bugs marked with "stalebug" whiteboard.

If this bug is still valid, please reopen and remove the "stalebug" keyword.