Shutdown fix

The GUI shutdown changes sometimes caused freezes on linux.
This commit is contained in:
Peter Šurda 2016-04-25 17:27:07 +02:00
parent be29a24a80
commit 0507411696

View File

@ -2668,14 +2668,14 @@ class MyForm(settingsmixin.SMainWindow):
if curWorkerQueue > 0: if curWorkerQueue > 0:
self.statusBar().showMessage(_translate("MainWindow", "Waiting for PoW to finish... %1%").arg(str(50 * (maxWorkerQueue - curWorkerQueue) / maxWorkerQueue))) self.statusBar().showMessage(_translate("MainWindow", "Waiting for PoW to finish... %1%").arg(str(50 * (maxWorkerQueue - curWorkerQueue) / maxWorkerQueue)))
time.sleep(0.5) time.sleep(0.5)
QtCore.QCoreApplication.processEvents() QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
self.statusBar().showMessage(_translate("MainWindow", "Shutting down Pybitmessage... %1%").arg(str(50))) self.statusBar().showMessage(_translate("MainWindow", "Shutting down Pybitmessage... %1%").arg(str(50)))
QtCore.QCoreApplication.processEvents() QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
if maxWorkerQueue > 0: if maxWorkerQueue > 0:
time.sleep(0.5) # a bit of time so that the hashHolder is populated time.sleep(0.5) # a bit of time so that the hashHolder is populated
QtCore.QCoreApplication.processEvents() QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
# check if objectHashHolder empty # check if objectHashHolder empty
self.statusBar().showMessage(_translate("MainWindow", "Waiting for objects to be sent... %1%").arg(str(50))) self.statusBar().showMessage(_translate("MainWindow", "Waiting for objects to be sent... %1%").arg(str(50)))
@ -2694,16 +2694,16 @@ class MyForm(settingsmixin.SMainWindow):
if curWaitingObjects > 0: if curWaitingObjects > 0:
self.statusBar().showMessage(_translate("MainWindow", "Waiting for objects to be sent... %1%").arg(str(50 + 20 * (maxWaitingObjects - curWaitingObjects) / maxWaitingObjects))) self.statusBar().showMessage(_translate("MainWindow", "Waiting for objects to be sent... %1%").arg(str(50 + 20 * (maxWaitingObjects - curWaitingObjects) / maxWaitingObjects)))
time.sleep(0.5) time.sleep(0.5)
QtCore.QCoreApplication.processEvents() QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
QtCore.QCoreApplication.processEvents() QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
if maxWorkerQueue > 0 or maxWaitingObjects > 0: if maxWorkerQueue > 0 or maxWaitingObjects > 0:
time.sleep(10) # a bit of time so that the other nodes retrieve the objects time.sleep(10) # a bit of time so that the other nodes retrieve the objects
QtCore.QCoreApplication.processEvents() QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
# save state and geometry self and all widgets # save state and geometry self and all widgets
self.statusBar().showMessage(_translate("MainWindow", "Saving settings... %1%").arg(str(70))) self.statusBar().showMessage(_translate("MainWindow", "Saving settings... %1%").arg(str(70)))
QtCore.QCoreApplication.processEvents() QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
self.saveSettings() self.saveSettings()
for attr, obj in self.ui.__dict__.iteritems(): for attr, obj in self.ui.__dict__.iteritems():
if hasattr(obj, "__class__") and isinstance(obj, settingsmixin.SettingsMixin): if hasattr(obj, "__class__") and isinstance(obj, settingsmixin.SettingsMixin):
@ -2712,17 +2712,15 @@ class MyForm(settingsmixin.SMainWindow):
obj.saveSettings() obj.saveSettings()
self.statusBar().showMessage(_translate("MainWindow", "Shutting down core... %1%").arg(str(80))) self.statusBar().showMessage(_translate("MainWindow", "Shutting down core... %1%").arg(str(80)))
QtCore.QCoreApplication.processEvents() QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
shared.doCleanShutdown() shared.doCleanShutdown()
self.statusBar().showMessage(_translate("MainWindow", "Stopping notifications... %1%").arg(str(90))) self.statusBar().showMessage(_translate("MainWindow", "Stopping notifications... %1%").arg(str(90)))
QtCore.QCoreApplication.processEvents()
self.tray.hide() self.tray.hide()
# unregister the messaging system # unregister the messaging system
if self.mmapp is not None: if self.mmapp is not None:
self.mmapp.unregister() self.mmapp.unregister()
self.statusBar().showMessage(_translate("MainWindow", "Shutdown imminent... %1%").arg(str(100))) self.statusBar().showMessage(_translate("MainWindow", "Shutdown imminent... %1%").arg(str(100)))
QtCore.QCoreApplication.processEvents()
shared.thisapp.cleanup() shared.thisapp.cleanup()
logger.info("Shutdown complete") logger.info("Shutdown complete")
os._exit(0) os._exit(0)