Skip to content

Commit 81203c6

Browse files
committed
Avoid showing UIs that have been disposed
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 963f205 commit 81203c6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/org/scijava/ui/DefaultUIService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ public void addUI(final String name, final UserInterface ui) {
154154

155155
@Override
156156
public void showUI() {
157+
if (!initialized) return;
157158
final UserInterface ui = getDefaultUI();
158159
if (ui == null) {
159160
throw new IllegalStateException("No UIs available.");
@@ -343,7 +344,7 @@ public String getStatusMessage(final StatusEvent statusEvent) {
343344
// -- Disposable methods --
344345

345346
@Override
346-
public void dispose() {
347+
public synchronized void dispose() {
347348
// dispose active display viewers
348349
// NB - copy list to avoid ConcurrentModificationExceptions
349350
final List<DisplayViewer<?>> viewers = new ArrayList<DisplayViewer<?>>();
@@ -357,6 +358,7 @@ public void dispose() {
357358
for (int i = uis.size() - 1; i >= 0; i--) {
358359
uis.get(i).dispose();
359360
}
361+
initialized = false;
360362
}
361363

362364
// -- Event handlers --

0 commit comments

Comments
 (0)