From 4532e397c0d7cbd31e2fa99056d202a742b3ac4a Mon Sep 17 00:00:00 2001 From: Emux Date: Tue, 5 Sep 2017 12:26:23 +0300 Subject: [PATCH] vtm-theme-comparator: fix application exit #387 --- .../org/oscim/theme/comparator/MainMenu.java | 13 +++++++------ .../org/oscim/theme/comparator/MainWindow.java | 17 ++++++++++------- .../oscim/theme/comparator/vtm/VtmPanel.java | 2 ++ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/vtm-theme-comparator/src/org/oscim/theme/comparator/MainMenu.java b/vtm-theme-comparator/src/org/oscim/theme/comparator/MainMenu.java index 64ab1e324..b432eaa49 100644 --- a/vtm-theme-comparator/src/org/oscim/theme/comparator/MainMenu.java +++ b/vtm-theme-comparator/src/org/oscim/theme/comparator/MainMenu.java @@ -1,5 +1,6 @@ /* * Copyright 2017 Longri + * Copyright 2017 devemux86 * * This program is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free Software @@ -35,15 +36,15 @@ public class MainMenu extends JMenuBar { - private final MapLoader mapLoader; + private final MainWindow mainWindow; private final JMenu fileMenu = new JMenu("File"); private final JMenu viewMenu = new JMenu("View"); private final JMenu posMenu = new JMenu("Pos"); private ThemeLoader themeLoader; - MainMenu(MapLoader mapLoader, BothMapPositionHandler mapPosition) { - this.mapLoader = mapLoader; - mapPosition.setCallBack(this); + MainMenu(MainWindow mainWindow) { + this.mainWindow = mainWindow; + mainWindow.bothMapPositionHandler.setCallBack(this); addFileEntrys(); addViewEntrys(); addPosEntrys(); @@ -86,7 +87,7 @@ private JMenuItem itemExit() { item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - System.exit(0); + mainWindow.exit(); } }); return item; @@ -114,7 +115,7 @@ public void actionPerformed(ActionEvent e) { ex.printStackTrace(); } - mapLoader.loadMap(new File(mapPath), true); + mainWindow.mapLoader.loadMap(new File(mapPath), true); } } }); diff --git a/vtm-theme-comparator/src/org/oscim/theme/comparator/MainWindow.java b/vtm-theme-comparator/src/org/oscim/theme/comparator/MainWindow.java index e4eab5fda..06ce5c365 100644 --- a/vtm-theme-comparator/src/org/oscim/theme/comparator/MainWindow.java +++ b/vtm-theme-comparator/src/org/oscim/theme/comparator/MainWindow.java @@ -33,8 +33,8 @@ class MainWindow extends JFrame { private final VtmPanel vtmPanel; - private final MapLoader mapLoader; - private final BothMapPositionHandler bothMapPositionHandler; + final MapLoader mapLoader; + final BothMapPositionHandler bothMapPositionHandler; private final MapsforgeMapPanel mapsforgeMapPanel; private final InfoPanel infoPanel; private final MapsPanel mapsPanel; @@ -66,7 +66,7 @@ public void run() { mapLoader = new MapLoader(mapsforgeMapPanel, vtmPanel, bothMapPositionHandler); - MainMenu mainMenu = new MainMenu(mapLoader, bothMapPositionHandler); + MainMenu mainMenu = new MainMenu(this); setJMenuBar(mainMenu); infoPanel = new InfoPanel(vtmPanel, mapsforgeMapPanel, mainMenu); @@ -86,12 +86,15 @@ public void run() { addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { - mapsforgeMapPanel.destroy(); - setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - dispose(); - System.exit(0); + exit(); } }); } + void exit() { + mapsforgeMapPanel.destroy(); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + dispose(); + System.exit(0); + } } diff --git a/vtm-theme-comparator/src/org/oscim/theme/comparator/vtm/VtmPanel.java b/vtm-theme-comparator/src/org/oscim/theme/comparator/vtm/VtmPanel.java index f22af2aff..87e350273 100644 --- a/vtm-theme-comparator/src/org/oscim/theme/comparator/vtm/VtmPanel.java +++ b/vtm-theme-comparator/src/org/oscim/theme/comparator/vtm/VtmPanel.java @@ -1,5 +1,6 @@ /* * Copyright 2017 Longri + * Copyright 2017 devemux86 * * This program is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free Software @@ -34,6 +35,7 @@ public class VtmPanel extends JPanel { public VtmPanel(MapApplicationAdapter.MapReadyCallback callback) { this.setLayout(null); + LwjglApplicationConfiguration.disableAudio = true; LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.width = 300; config.height = 300;