Fix crash when clearing build plate

We shouldn't delete the singleton PrintInformation object. We should rather just zero out the print information. And instead of doing that explicitly in deleteAll, listen to scene changes from PrintInformation in order to keep the logic related to the print information contained within its class.

Contributes to issue CURA-4810.
This commit is contained in:
Ghostkeeper 2018-01-16 13:43:28 +01:00
parent 51b49c89f4
commit f948203a63
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A
2 changed files with 3 additions and 5 deletions

View file

@ -1061,9 +1061,6 @@ class CuraApplication(QtApplication):
op.push() op.push()
Selection.clear() Selection.clear()
Logger.log("i", "Reseting print information")
self._print_information = PrintInformation.PrintInformation()
# stay on the same build plate # stay on the same build plate
#self.getCuraSceneController().setActiveBuildPlate(0) # Select first build plate #self.getCuraSceneController().setActiveBuildPlate(0) # Select first build plate

View file

@ -1,4 +1,4 @@
# Copyright (c) 2017 Ultimaker B.V. # Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from PyQt5.QtCore import QObject, pyqtSignal, pyqtProperty from PyQt5.QtCore import QObject, pyqtSignal, pyqtProperty
@ -65,6 +65,7 @@ class PrintInformation(QObject):
self._backend = Application.getInstance().getBackend() self._backend = Application.getInstance().getBackend()
if self._backend: if self._backend:
self._backend.printDurationMessage.connect(self._onPrintDurationMessage) self._backend.printDurationMessage.connect(self._onPrintDurationMessage)
Application.getInstance().getController().getScene().sceneChanged.connect(self.setToZeroPrintInformation)
self._base_name = "" self._base_name = ""
self._abbr_machine = "" self._abbr_machine = ""
@ -171,7 +172,7 @@ class PrintInformation(QObject):
def printTimes(self): def printTimes(self):
return self._print_time_message_values[self._active_build_plate] return self._print_time_message_values[self._active_build_plate]
def _onPrintDurationMessage(self, build_plate_number, print_time, material_amounts): def _onPrintDurationMessage(self, build_plate_number, print_time: Dict[str, int], material_amounts: list):
self._updateTotalPrintTimePerFeature(build_plate_number, print_time) self._updateTotalPrintTimePerFeature(build_plate_number, print_time)
self.currentPrintTimeChanged.emit() self.currentPrintTimeChanged.emit()