File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -173,7 +173,18 @@ public CCombo (Composite parent, int style) {
173173 }
174174
175175 initAccessible ();
176- addListener (SWT .ZoomChanged , this ::handleDPIChange );
176+
177+ // Add listener asynchronously in order to delay execution. This works because
178+ // other DPI changes are also executed asynchronously but if we choose to revert
179+ // back to synchronous execution of the listeners then this async call may be
180+ // executed too late and zoom change events may happen too early and not get
181+ // propagated.
182+ // See https://github.com/eclipse-platform/eclipse.platform.swt/issues/2733
183+ getDisplay ().asyncExec (() -> {
184+ if (!isDisposed ()) {
185+ addListener (SWT .ZoomChanged , this ::handleDPIChange );
186+ }
187+ });
177188}
178189static int checkStyle (int style ) {
179190 int mask = SWT .BORDER | SWT .READ_ONLY | SWT .FLAT | SWT .LEFT_TO_RIGHT | SWT .RIGHT_TO_LEFT | SWT .LEAD | SWT .CENTER | SWT .TRAIL ;
Original file line number Diff line number Diff line change @@ -758,7 +758,18 @@ public StyledText(Composite parent, int style) {
758758 initializeAccessible ();
759759 setData ("DEFAULT_DROP_TARGET_EFFECT" , new StyledTextDropTargetEffect (this ));
760760 if (IS_MAC ) setData (STYLEDTEXT_KEY );
761- addListener (SWT .ZoomChanged , this ::handleDPIChange );
761+
762+ // Add listener asynchronously in order to delay execution. This works because
763+ // other DPI changes are also executed asynchronously but if we choose to revert
764+ // back to synchronous execution of the listeners then this async call may be
765+ // executed too late and zoom change events may happen too early and not get
766+ // propagated.
767+ // See https://github.com/eclipse-platform/eclipse.platform.swt/issues/2733
768+ getDisplay ().asyncExec (() -> {
769+ if (!isDisposed ()) {
770+ addListener (SWT .ZoomChanged , this ::handleDPIChange );
771+ }
772+ });
762773}
763774/**
764775 * Adds an extended modify listener. An ExtendedModify event is sent by the
You can’t perform that action at this time.
0 commit comments