Skip to content

Colors are null in Section onPaint and cause null pointer exception #2972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
selundqma opened this issue May 12, 2025 · 2 comments · Fixed by #2973
Closed

Colors are null in Section onPaint and cause null pointer exception #2972

selundqma opened this issue May 12, 2025 · 2 comments · Fixed by #2973
Labels
bug Something isn't working regression

Comments

@selundqma
Copy link
Contributor

selundqma commented May 12, 2025

Changed code found in Section.class (onPaint) which lets null values slip through and cause null pointer exception.

OS: Windows 11
JDK: 21.0.6.7.1

Eclipse 2024-12

	Color bg = null;
	Color fg = null;
	Color border = null;

...

	if (titleColors != null) {
		bg = titleColors.get(COLOR_BG);
		fg = getTitleBarForeground();           // -> still null
		border = titleColors.get(COLOR_BORDER); // -> still null
	}
	if (bg == null)
		bg = getBackground();
	if (fg == null)
		fg = getForeground();
	if (border == null)
		border = fg;

	// All are set now... no null values.. works fine later on to use them

Eclipse 2025-06 M2

	Color bg = (titleColors != null) ? titleColors.getOrDefault(COLOR_BG, getBackground()) : getBackground(); 
	Color fg = (titleColors != null) ? getTitleBarForeground() : getForeground(); 			// -> still null
	Color border = (titleColors != null) ? titleColors.getOrDefault(COLOR_BORDER, fg) : fg; 	// -> still null

	// BANG!! fg and border are still null and are used in a later call (gc.setForeground(border));

Stack trace:
java.lang.IllegalArgumentException: Argument cannot be null
at org.eclipse.swt.SWT.error(SWT.java:4926)
at org.eclipse.swt.SWT.error(SWT.java:4860)
at org.eclipse.swt.SWT.error(SWT.java:4831)
at org.eclipse.swt.graphics.GC.setForeground(GC.java:4422)
at org.eclipse.ui.forms.widgets.Section.lambda$1(Section.java:375)
at org.eclipse.swt.graphics.Image$ImageGcDrawerWrapper.newImageHandle(Image.java:2530)
at org.eclipse.swt.graphics.Image.getImageMetadata(Image.java:782)
at org.eclipse.swt.graphics.Image.win32_getHandle(Image.java:806)
at org.eclipse.swt.graphics.GC.drawBitmap(GC.java:1210)
at org.eclipse.swt.graphics.GC.drawImage(GC.java:1070)
at org.eclipse.swt.graphics.GC.drawImageInPixels(GC.java:944)
at org.eclipse.swt.graphics.GC.drawImage(GC.java:937)
at org.eclipse.ui.forms.widgets.Section.onPaint(Section.java:431)
at org.eclipse.ui.forms.widgets.ExpandableComposite.lambda$0(ExpandableComposite.java:574)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:268)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4338)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1208)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1232)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1217)
at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1645)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4835)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:336)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5106)
at org.eclipse.swt.internal.win32.OS.UpdateWindow(Native Method)
at org.eclipse.swt.widgets.Decorations.setVisible(Decorations.java:1325)
at org.eclipse.swt.widgets.Shell.setVisible(Shell.java:2133)
at org.eclipse.swt.widgets.Shell.open(Shell.java:1297)
at org.eclipse.jface.window.Window.open(Window.java:795)
at com.greg.cs.ma3.client.yuuuf.ui.serviceupdate.ServerUpdateHandler.execute(ServerUpdateHandler.java:84)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:299)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:233)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:174)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:165)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:488)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:485)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:204)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:444)
at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.handleWidgetSelection(AbstractContributionItem.java:455)
at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.lambda$2(AbstractContributionItem.java:477)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4338)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1208)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4136)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3724)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1042)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:165)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:219)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:149)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:115)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:467)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:298)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:627)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1431)
at org.eclipse.equinox.launcher.Main.main(Main.java:1403)

@selundqma selundqma added the bug Something isn't working label May 12, 2025
@iloveeclipse
Copy link
Member

@selundqma : I assume you are referring to d4ffd3f change.
Do you want to provide a fix?

@ShahzaibIbrahim : could you please check? The code in question was changed via #2861.

@selundqma
Copy link
Contributor Author

Sure, I can provide a fix. I think the issue appeared already in the b3513d1 change where the null checks were removed.

selundqma added a commit to selundqma/eclipse.platform.ui that referenced this issue May 12, 2025
…clipse-platform#2972

Changed code found in Section.class (onPaint) which lets
null values slip through and cause null pointer exception.

Fixes eclipse-platform#2972
fedejeanne pushed a commit that referenced this issue May 13, 2025
…2972

Changed code found in Section.class (onPaint) which lets
null values slip through and cause null pointer exception.

Fixes #2972
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression
Projects
None yet
2 participants