source: josm/trunk/src/org/openstreetmap/josm/gui/MainTermination.java@ 14159

Last change on this file since 14159 was 14153, checked in by Don-vip, 6 years ago

see #15229 - deprecate Main.parent and Main itself

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.io.IOException;
7import java.nio.file.InvalidPathException;
8
9import org.openstreetmap.josm.data.Preferences;
10import org.openstreetmap.josm.data.cache.JCSCacheManager;
11import org.openstreetmap.josm.tools.ImageProvider;
12import org.openstreetmap.josm.tools.Logging;
13
14/**
15 * JOSM termination sequence.
16 * @since 14140
17 */
18public class MainTermination implements Runnable {
19
20 @Override
21 public void run() {
22 try {
23 MainApplication.worker.shutdown();
24 } catch (SecurityException e) {
25 Logging.log(Logging.LEVEL_ERROR, "Unable to shutdown worker", e);
26 }
27 JCSCacheManager.shutdown();
28
29 if (MainApplication.getMainFrame() != null) {
30 MainApplication.getMainFrame().storeState();
31 }
32 if (MainApplication.getMap() != null) {
33 MainApplication.getMap().rememberToggleDialogWidth();
34 }
35 // Remove all layers because somebody may rely on layerRemoved events (like AutosaveTask)
36 MainApplication.getLayerManager().resetState();
37 ImageProvider.shutdown(false);
38 try {
39 Preferences.main().saveDefaults();
40 } catch (IOException | InvalidPathException ex) {
41 Logging.log(Logging.LEVEL_WARN, tr("Failed to save default preferences."), ex);
42 }
43 ImageProvider.shutdown(true);
44
45 try {
46 // in case the current task still hasn't finished
47 MainApplication.worker.shutdownNow();
48 } catch (SecurityException e) {
49 Logging.log(Logging.LEVEL_ERROR, "Unable to shutdown worker", e);
50 }
51 }
52}
53
Note: See TracBrowser for help on using the repository browser.