Skip to content

Commit 671c7ae

Browse files
committed
UI component being attempted to be disposed in a non-ui thread.
1 parent dc1eea9 commit 671c7ae

File tree

2 files changed

+29
-8
lines changed
  • bundles

2 files changed

+29
-8
lines changed

bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/EditActionGroup.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2006, 2015 IBM Corporation and others.
2+
* Copyright (c) 2006, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -18,8 +18,10 @@
1818
import org.eclipse.jface.action.IMenuManager;
1919
import org.eclipse.jface.viewers.IStructuredSelection;
2020
import org.eclipse.swt.SWT;
21+
import org.eclipse.swt.SWTException;
2122
import org.eclipse.swt.dnd.Clipboard;
2223
import org.eclipse.swt.events.KeyEvent;
24+
import org.eclipse.swt.widgets.Display;
2325
import org.eclipse.swt.widgets.Shell;
2426
import org.eclipse.ui.IActionBars;
2527
import org.eclipse.ui.ISharedImages;
@@ -55,11 +57,25 @@ public EditActionGroup(Shell aShell) {
5557

5658
@Override
5759
public void dispose() {
58-
if (clipboard != null) {
59-
clipboard.dispose();
60-
clipboard = null;
60+
Display display = Display.getDefault();
61+
if (display != null && !display.isDisposed()) {
62+
display.asyncExec(() -> {
63+
if (clipboard != null && !clipboard.isDisposed()) {
64+
clipboard.dispose();
65+
clipboard = null;
66+
}
67+
});
68+
} else {
69+
// Avoid disposing UI resources if display is gone
70+
if (clipboard != null && !clipboard.isDisposed()) {
71+
try {
72+
clipboard.dispose();
73+
clipboard = null;
74+
} catch (SWTException e) {
75+
// Log or ignore safely
76+
}
77+
}
6178
}
62-
super.dispose();
6379
}
6480

6581
@Override

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/e4/compatibility/CompatibilityPart.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2010, 2016 IBM Corporation and others.
2+
* Copyright (c) 2010, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -32,6 +32,7 @@
3232
import org.eclipse.e4.ui.di.Focus;
3333
import org.eclipse.e4.ui.di.Persist;
3434
import org.eclipse.e4.ui.di.PersistState;
35+
import org.eclipse.e4.ui.di.UISynchronize;
3536
import org.eclipse.e4.ui.internal.workbench.Activator;
3637
import org.eclipse.e4.ui.internal.workbench.Policy;
3738
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
@@ -418,9 +419,13 @@ public void create() {
418419
}
419420

420421
@PreDestroy
421-
void destroy() {
422+
void destroy(UISynchronize sync) {
422423
if (!alreadyDisposed) {
423-
invalidate();
424+
sync.syncExec(() -> {
425+
if (!alreadyDisposed) {
426+
invalidate();
427+
}
428+
});
424429
}
425430

426431
eventBroker.unsubscribe(widgetSetHandler);

0 commit comments

Comments
 (0)