Fix AutoSave crashing the early crash dialog

CURA-4895
This commit is contained in:
Lipu Fei 2018-02-01 16:39:56 +01:00 committed by Diego Prado Gesto
parent 547baff239
commit b59eadce1c
4 changed files with 18 additions and 13 deletions

View file

@ -66,7 +66,10 @@ class CrashHandler:
for part in line.rstrip("\n").split("\n"):
Logger.log("c", part)
if exception_type not in fatal_exception_types:
# If Cura has fully started, we only show fatal errors.
# If Cura has not fully started yet, we always show the early crash dialog. Otherwise, Cura will just crash
# without any information.
if has_started and exception_type not in fatal_exception_types:
return
self._send_report_checkbox = None

View file

@ -106,14 +106,6 @@ if not MYPY:
CuraDebugMode = False
#
# A global signal which is triggered when CuraApplication has finished its start up.
# This is used to initialise some plugins such as AutoSave which should only be started after the application passed
# the start up successfully.
#
applicationStarted = pyqtSignal()
class CuraApplication(QtApplication):
# SettingVersion represents the set of settings available in the machine/extruder definitions.
# You need to make sure that this version number needs to be increased if there is any non-backwards-compatible

View file

@ -108,6 +108,7 @@ def exceptHook(hook_type, value, traceback):
sys.exit(1)
else:
application = QApplication(sys.argv)
application.removePostedEvents(None)
_crash_handler = CrashHandler(hook_type, value, traceback, has_started)
_crash_handler.early_crash_dialog.show()
sys.exit(application.exec_())

View file

@ -30,12 +30,21 @@ class AutoSave(Extension):
# At this point, the Application instance has not finished its constructor call yet, so directly using something
# like Application.getInstance() is not correct. The initialisation now will only gets triggered after the
# application finishes its start up successfully.
from cura.CuraApplication import applicationStarted
applicationStarted.connect(self.initialize)
self._init_timer = QTimer()
self._init_timer.setInterval(1000)
self._init_timer.setSingleShot(True)
self._init_timer.timeout.connect(self.initialize)
self._init_timer.start()
def initialize(self):
from cura.CuraApplication import applicationStarted
applicationStarted.disconnect(self.initialize)
# only initialise if the application is created and has started
from cura.CuraApplication import CuraApplication
if not CuraApplication.Created:
self._init_timer.start()
return
if not CuraApplication.getInstance().started:
self._init_timer.start()
return
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalStackChanged)
self._onGlobalStackChanged()