-
Notifications
You must be signed in to change notification settings - Fork 188
Closed
Description
Describe the bug
The Widget constructor
eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
Lines 179 to 197 in a9598b8
| public Widget (Widget parent, int style) { | |
| checkSubclass (); | |
| checkParent (parent); | |
| this.style = style; | |
| this.nativeZoom = parent != null ? parent.nativeZoom : DPIUtil.getNativeDeviceZoom(); | |
| display = parent.display; | |
| reskinWidget (); | |
| notifyCreationTracker(); | |
| registerDPIChangeListener(); | |
| } | |
| void registerDPIChangeListener() { | |
| if (display.isRescalingAtRuntime()) { | |
| this.addListener(SWT.ZoomChanged, event -> { | |
| float scalingFactor = 1f * DPIUtil.getZoomForAutoscaleProperty(event.detail) / DPIUtil.getZoomForAutoscaleProperty(nativeZoom); | |
| handleDPIChange(event, scalingFactor); | |
| }); | |
| } | |
| } |
calls via registerDPIChangeListener the public and overrideable method addListener. If that method is overridden in a subclass it will run before the subclass instance is initialized. This is bad practice, and in fact it breaks EGit's FindToolbar: see eclipse-egit/egit#117 .
Possible fix
Replace the call to this.addListener at
eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
Line 192 in a9598b8
| this.addListener(SWT.ZoomChanged, event -> { |
by this._addListener (with underscore, package-private).
Metadata
Metadata
Assignees
Labels
No labels