diff --git a/src/main/java/io/github/dsheirer/gui/JavaFxWindowManager.java b/src/main/java/io/github/dsheirer/gui/JavaFxWindowManager.java index eb99edba2..4be3d9dd5 100644 --- a/src/main/java/io/github/dsheirer/gui/JavaFxWindowManager.java +++ b/src/main/java/io/github/dsheirer/gui/JavaFxWindowManager.java @@ -43,6 +43,7 @@ import io.github.dsheirer.monitor.StatusBox; import io.github.dsheirer.preference.UserPreferences; import jakarta.annotation.PostConstruct; +import jakarta.annotation.PreDestroy; import jakarta.annotation.Resource; import javafx.application.Application; import javafx.application.Platform; @@ -53,6 +54,10 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** * Java FX window manager. Handles all secondary Java FX windows that are used within this primarily * Swing application. @@ -96,6 +101,7 @@ public class JavaFxWindowManager extends Application private Stage mPlaylistStage; private Stage mUserPreferencesStage; private Stage mRecordingViewerStage; + private List mStages = new ArrayList<>(); /** * Constructs an instance. Note: this constructor is used for Swing applications. @@ -154,7 +160,27 @@ public void shutdown() { MyEventBus.getGlobalEventBus().unregister(this); mUserPreferences.getJavaFxPreferences().clearStageMonitors(); - Platform.exit(); + + Platform.runLater(() -> + { + Iterator it = mStages.iterator(); + + while(it.hasNext()) + { + try + { + it.next().close(); + } + catch(Throwable t) + { + //Do nothing ... we're shutting down + } + + it.remove(); + } + + Platform.exit(); + }); } public CalibrationDialog getCalibrationDialog(UserPreferences userPreferences) @@ -173,6 +199,7 @@ public Stage getRecordingViewerStage() mRecordingViewerStage = new Stage(); mRecordingViewerStage.setTitle("sdrtrunk - Message Recording Viewer (.bits)"); mRecordingViewerStage.setScene(scene); + mStages.add(mRecordingViewerStage); mUserPreferences.getJavaFxPreferences().monitor(mRecordingViewerStage, STAGE_MONITOR_KEY_RECORDING_VIEWER); } @@ -197,6 +224,7 @@ public Stage getIconManagerStage() mIconManagerStage = new Stage(); mIconManagerStage.setTitle("sdrtrunk - Icon Manager"); mIconManagerStage.setScene(scene); + mStages.add(mIconManagerStage); mUserPreferences.getJavaFxPreferences().monitor(mIconManagerStage, STAGE_MONITOR_KEY_ICON_MANAGER_EDITOR); } @@ -239,6 +267,7 @@ public Stage getJmbeEditorStage() mJmbeEditorStage = new Stage(); mJmbeEditorStage.setTitle("sdrtrunk - JMBE Library Updater"); mJmbeEditorStage.setScene(scene); + mStages.add(mJmbeEditorStage); mUserPreferences.getJavaFxPreferences().monitor(mJmbeEditorStage, STAGE_MONITOR_KEY_JMBE_EDITOR); } @@ -269,6 +298,7 @@ private Stage getPlaylistStage() mPlaylistStage = new Stage(); mPlaylistStage.setTitle("sdrtrunk - Playlist Editor"); mPlaylistStage.setScene(scene); + mStages.add(mPlaylistStage); mUserPreferences.getJavaFxPreferences().monitor(mPlaylistStage, STAGE_MONITOR_KEY_PLAYLIST_EDITOR); } @@ -313,6 +343,7 @@ private Stage getUserPreferencesStage() mUserPreferencesStage = new Stage(); mUserPreferencesStage.setTitle("sdrtrunk - User Preferences"); mUserPreferencesStage.setScene(scene); + mStages.add(mUserPreferencesStage); mUserPreferences.getJavaFxPreferences().monitor(mUserPreferencesStage, STAGE_MONITOR_KEY_USER_PREFERENCES_EDITOR); } @@ -350,6 +381,7 @@ private Stage getChannelMapStage() mChannelMapStage = new Stage(); mChannelMapStage.setTitle("sdrtrunk - Channel Map Editor"); mChannelMapStage.setScene(scene); + mStages.add(mChannelMapStage); mUserPreferences.getJavaFxPreferences().monitor(mChannelMapStage, STAGE_MONITOR_KEY_CHANNEL_MAP_EDITOR); }