Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365525 - MinMax addon throws NPE when no perspective is available
Summary: MinMax addon throws NPE when no perspective is available
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: PC Windows 7
: P3 major with 1 vote (vote)
Target Milestone: 4.14 M1   Edit
Assignee: Christoph Laeubrich CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-04 11:03 EST by Kai Toedter CLA
Modified: 2019-09-25 02:54 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kai Toedter CLA 2011-12-04 11:03:19 EST
Perspectives are optional in the Workbench model. The MinMax addon throws an NPE, when no perspective is available. Fixes:

Project org.eclipse.e4.ui.workbench.addons.swt
Class MinMaxAddon.java

	private int getCachedIndex(MUIElement element) {
		MPerspective persp = modelService.getPerspectiveFor(element);
		if (persp == null)
			return -1;
...

	private SideValue getCachedBar(MUIElement element) {
		MPerspective persp = modelService.getPerspectiveFor(element);
		if (persp == null)
			return null;
...

I could commit that myself, but I would like Eric to review the fix :)
Comment 1 Remy Suen CLA 2011-12-04 17:52:27 EST
(In reply to comment #0)
>     private SideValue getCachedBar(MUIElement element) {
>         MPerspective persp = modelService.getPerspectiveFor(element);
>         if (persp == null)
>             return null;

Indeed, see bug 365192.

> I could commit that myself, but I would like Eric to review the fix :)

Eric, could you take a look at this?
Comment 2 Christoph Laeubrich CLA 2019-09-21 01:55:11 EDT
Even tough the code has changed in the past 8 years, the problem (and similar missing null checks) still persist. I'll provide a patch for this, would be good if someone can review it then.
Comment 3 Eclipse Genie CLA 2019-09-21 01:58:43 EDT
New Gerrit change created: https://git.eclipse.org/r/149942
Comment 4 Matthias Becker CLA 2019-09-23 03:25:23 EDT
(In reply to Kai Toedter from comment #0)
> Perspectives are optional in the Workbench model. The MinMax addon throws an
> NPE, when no perspective is available. Fixes:
> 
> Project org.eclipse.e4.ui.workbench.addons.swt
> Class MinMaxAddon.java
> 
> 	private int getCachedIndex(MUIElement element) {
> 		MPerspective persp = modelService.getPerspectiveFor(element);
> 		if (persp == null)
> 			return -1;
> ...
> 
> 	private SideValue getCachedBar(MUIElement element) {
> 		MPerspective persp = modelService.getPerspectiveFor(element);
> 		if (persp == null)
> 			return null;
> ...
> 
> I could commit that myself, but I would like Eric to review the fix :)

How can I reproduce this NPE? What steps do I need to perform?
Comment 6 Matthias Becker CLA 2019-09-25 02:54:13 EDT
Thanks Christoph for fixing this very old bug.