mirror of https://github.com/zlatinb/muwire
proper shutdown if core isn't created yet
parent
c038846ff3
commit
5e23c1b823
|
@ -47,14 +47,12 @@ class Ready extends AbstractLifecycleHandler {
|
||||||
def home = new File(application.getContext().getAsString("muwire-home"))
|
def home = new File(application.getContext().getAsString("muwire-home"))
|
||||||
def props = new Properties()
|
def props = new Properties()
|
||||||
def propsFile = new File(home, "MuWire.properties")
|
def propsFile = new File(home, "MuWire.properties")
|
||||||
if (propsFile.exists()) {
|
if (propsFile.exists() && propsFile.length() > 0) {
|
||||||
log.info("loading existing props file")
|
log.info("loading existing props file")
|
||||||
propsFile.withReader("UTF-8", {
|
propsFile.withReader("UTF-8", {
|
||||||
props.load(it)
|
props.load(it)
|
||||||
})
|
})
|
||||||
props = new MuWireSettings(props)
|
props = new MuWireSettings(props)
|
||||||
if (props.incompleteLocation == null)
|
|
||||||
props.incompleteLocation = new File(home, "incompletes")
|
|
||||||
|
|
||||||
if (System.getProperties().containsKey("disableUpdates"))
|
if (System.getProperties().containsKey("disableUpdates"))
|
||||||
props.disableUpdates = Boolean.valueOf(System.getProperty("disableUpdates"))
|
props.disableUpdates = Boolean.valueOf(System.getProperty("disableUpdates"))
|
||||||
|
@ -125,7 +123,7 @@ class Ready extends AbstractLifecycleHandler {
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(null, trans(key),
|
JOptionPane.showMessageDialog(null, trans(key),
|
||||||
trans("CORE_INIT_ERROR_HEADER"), JOptionPane.WARNING_MESSAGE)
|
trans("CORE_INIT_ERROR_HEADER"), JOptionPane.WARNING_MESSAGE)
|
||||||
System.exit(0)
|
application.shutdown()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2236,7 +2236,20 @@ class MainFrameView {
|
||||||
}
|
}
|
||||||
|
|
||||||
void closeApplication() {
|
void closeApplication() {
|
||||||
|
application.getWindowManager().findWindow("shutdown-window")?.setVisible(true)
|
||||||
|
JFrame mainFrame = builder.getVariable("main-frame")
|
||||||
|
mainFrame.setVisible(false)
|
||||||
|
|
||||||
Core core = application.getContext().get("core")
|
Core core = application.getContext().get("core")
|
||||||
|
if (core == null) {
|
||||||
|
// save UI settings so language dialog does not appear again
|
||||||
|
if (settings != null) {
|
||||||
|
File uiPropsFile = new File(application.context.getAsString("muwire-home"), "gui.properties")
|
||||||
|
uiPropsFile.withOutputStream {settings.write(it)}
|
||||||
|
}
|
||||||
|
application.shutdown()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
def tabbedPane = builder.getVariable("result-tabs")
|
def tabbedPane = builder.getVariable("result-tabs")
|
||||||
settings.openTabs.clear()
|
settings.openTabs.clear()
|
||||||
|
@ -2246,20 +2259,16 @@ class MainFrameView {
|
||||||
settings.openTabs.removeAll(model.browses)
|
settings.openTabs.removeAll(model.browses)
|
||||||
settings.openTabs.removeAll(model.collections)
|
settings.openTabs.removeAll(model.collections)
|
||||||
|
|
||||||
JFrame mainFrame = builder.getVariable("main-frame")
|
|
||||||
settings.mainFrameX = mainFrame.getSize().width
|
settings.mainFrameX = mainFrame.getSize().width
|
||||||
settings.mainFrameY = mainFrame.getSize().height
|
settings.mainFrameY = mainFrame.getSize().height
|
||||||
mainFrame.setVisible(false)
|
File uiPropsFile = new File(core.home, "gui.properties")
|
||||||
application.getWindowManager().findWindow("shutdown-window")?.setVisible(true)
|
uiPropsFile.withOutputStream { settings.write(it) }
|
||||||
if (core != null) {
|
|
||||||
Thread t = new Thread({
|
Thread t = new Thread({
|
||||||
core.shutdown()
|
core.shutdown()
|
||||||
application.shutdown()
|
application.shutdown()
|
||||||
}as Runnable)
|
}as Runnable)
|
||||||
t.start()
|
t.start()
|
||||||
File uiPropsFile = new File(core.home, "gui.properties")
|
|
||||||
uiPropsFile.withOutputStream { settings.write(it) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ResultTabsChangeListener implements ChangeListener {
|
private class ResultTabsChangeListener implements ChangeListener {
|
||||||
|
|
Loading…
Reference in New Issue