Optimize the logic of abnormal exit prompt
This commit is contained in:
parent
bf8aa6c514
commit
9117bb8fcd
11
Galactic.py
11
Galactic.py
|
@ -1894,13 +1894,13 @@ class MainWindow(QMainWindow):
|
|||
super().__init__()
|
||||
self.runner = runner
|
||||
try:
|
||||
if (os.path.exists(runner.app_last_exit_code) and open(runner.app_last_exit_code, mode='r').read() != '0') == 1:
|
||||
if (os.path.exists(self.runner.app_running_file)) == 1:
|
||||
QMessageBox.information(self, 'Warning', 'The application was not exited normally last time. Please wait for recovery.')
|
||||
self.runner.web_server.browser_manager.restore_last_status()
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
open(self.runner.app_last_exit_code, mode='w').write('')
|
||||
open(self.runner.app_running_file, mode='w').close()
|
||||
self.scale_rate = scale_rate
|
||||
self.web_listen_host = web_listen_host
|
||||
self.web_listen_port = web_listen_port
|
||||
|
@ -1975,7 +1975,10 @@ class MainWindow(QMainWindow):
|
|||
self.webview.load(QUrl('about:blank'))
|
||||
self.webview.deleteLater()
|
||||
self.runner.handle_interrupt()
|
||||
open(self.runner.app_last_exit_code, mode='w').write('0')
|
||||
try:
|
||||
os.remove(self.runner.app_running_file)
|
||||
except Exception:
|
||||
pass
|
||||
QApplication.quit()
|
||||
|
||||
def window_show(self):
|
||||
|
@ -2283,7 +2286,7 @@ class MainRunner:
|
|||
self.app_root = os.path.dirname(__file__)
|
||||
appdata = os.getenv('APPDATA')
|
||||
self.app_data = os.path.join(appdata, 'Galactic') if appdata else os.path.join(os.path.dirname(__file__), 'data')
|
||||
self.app_last_exit_code = os.path.join(self.app_data, 'exit')
|
||||
self.app_running_file = os.path.join(self.app_data, 'running')
|
||||
self.app_name = 'Galactic'
|
||||
self.app_version = '1.0.0.2'
|
||||
self.web_server_host = '127.0.0.1'
|
||||
|
|
Loading…
Reference in New Issue