Skip to content

[WSL] StyledText can send SWT.Skin event too early #3458

Description

@tmssngr

Describe the bug
A customer running Ubuntu 22.04 in WSL reported us following (deobfuscated) exception:

java.lang.NullPointerException
	at org.eclipse.swt.custom.StyledText.setForeground(SourceFile:8888)
	at com.syntevo.q.gui.theme.QThemeUtils.setForeground(SourceFile:67)
	at com.syntevo.q.gui.theme.QTheme.setForeground(SourceFile:462)
	at com.syntevo.q.gui.theme.QTheme.setBackAndForeground(SourceFile:431)
	at com.syntevo.q.gui.theme.QTheme.setBackAndForeground(SourceFile:427)
	at com.syntevo.q.gui.theme.QTheme.handleStyledText(SourceFile:360)
	at com.syntevo.q.gui.theme.QTheme.handleWidget(SourceFile:144)
	at com.syntevo.q.gui.theme.QThemeManager.lambda$new$0(SourceFile:23)
	at org.eclipse.swt.widgets.EventTable.sendEvent(SourceFile:91)
	at org.eclipse.swt.widgets.Display.sendEvent(SourceFile:5838)
	at org.eclipse.swt.widgets.Display.sendEvent(SourceFile:5830)
	at org.eclipse.swt.widgets.Display.runSkin(SourceFile:5134)
	at org.eclipse.swt.widgets.Composite.updateLayout(SourceFile:1863)
	at org.eclipse.swt.widgets.Composite.layout(SourceFile:1167)
	at org.eclipse.swt.widgets.Display.dpiChanged(SourceFile:5003)
	at org.eclipse.swt.widgets.Widget.dpiChanged(SourceFile:584)
	at org.eclipse.swt.widgets.Widget.notifyProc(SourceFile:2565)
	at org.eclipse.swt.widgets.Display.notifyProc(SourceFile:6127)
	at org.eclipse.swt.internal.gtk3.GTK3.gtk_container_add
	at org.eclipse.swt.widgets.Control.showWidget(SourceFile:6357)
	at org.eclipse.swt.widgets.Scrollable.showWidget(SourceFile:647)
	at org.eclipse.swt.widgets.Composite.showWidget(SourceFile:1806)
	at org.eclipse.swt.widgets.Control.createWidget(SourceFile:785)
	at org.eclipse.swt.widgets.Scrollable.createWidget(SourceFile:176)
	at org.eclipse.swt.widgets.Control.<init>(SourceFile:168)
	at org.eclipse.swt.widgets.Scrollable.<init>(SourceFile:85)
	at org.eclipse.swt.widgets.Composite.<init>(SourceFile:148)
	at org.eclipse.swt.widgets.Canvas.<init>(SourceFile:78)
	at org.eclipse.swt.custom.StyledText.<init>(SourceFile:718)
	at com.syntevo.sc.application.notification.ScNotificationOverlay.createWrappingStyledText(SourceFile:369)
	...

In short: while creating a StyledText, it sends an SWT.Skin event causing our listener trying to set a foreground color, but this fails, because the content is not yet set. IMHO, the SWT.Skin event is sent too early while the StyledText is not yet fully set up.

To Reproduce
I've tried to reproduce myself, but can't.

Expected behavior
The SWT.Skin event must only be sent if the controls are fully set up.

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux/WSL
    • macOS

Version
Our SWT is based on commit 227b646 "v4972r4".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions