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

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

fix #4535, fix #16780 - detect changesets closed on server side after 1 hour

  • Property svn:eol-style set to native
File size: 2.0 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.io.ChangesetUpdater;
12import org.openstreetmap.josm.io.MessageNotifier;
13import org.openstreetmap.josm.io.remotecontrol.RemoteControl;
14import org.openstreetmap.josm.tools.ImageProvider;
15import org.openstreetmap.josm.tools.Logging;
16
17/**
18 * JOSM termination sequence.
19 * @since 14140
20 */
21public class MainTermination implements Runnable {
22
23 @Override
24 public void run() {
25 ChangesetUpdater.stop();
26 MessageNotifier.stop();
27 RemoteControl.stop();
28
29 try {
30 MainApplication.worker.shutdown();
31 } catch (SecurityException e) {
32 Logging.log(Logging.LEVEL_ERROR, "Unable to shutdown worker", e);
33 }
34 JCSCacheManager.shutdown();
35
36 if (MainApplication.getMainFrame() != null) {
37 MainApplication.getMainFrame().storeState();
38 }
39 if (MainApplication.getMap() != null) {
40 MainApplication.getMap().rememberToggleDialogWidth();
41 }
42 // Remove all layers because somebody may rely on layerRemoved events (like AutosaveTask)
43 MainApplication.getLayerManager().resetState();
44 ImageProvider.shutdown(false);
45 try {
46 Preferences.main().saveDefaults();
47 } catch (IOException | InvalidPathException ex) {
48 Logging.log(Logging.LEVEL_WARN, tr("Failed to save default preferences."), ex);
49 }
50 ImageProvider.shutdown(true);
51
52 try {
53 // in case the current task still hasn't finished
54 MainApplication.worker.shutdownNow();
55 } catch (SecurityException e) {
56 Logging.log(Logging.LEVEL_ERROR, "Unable to shutdown worker", e);
57 }
58 }
59}
60
Note: See TracBrowser for help on using the repository browser.