mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-07 05:53:59 -06:00
Turn MaterialManagementModel into a singleton
Just like MaterialManager used to be. There can be only one instance of the page then. This prevents a crash when Qt deletes the QObject because it's no longer used in the page when you close the preferences screen. But when you open it again it doesn't construct a new one. Now there is always one instance so that's not a problem any more. Also it allows other pages to access this item. Contributes to issue CURA-6600.
This commit is contained in:
parent
b60b13e5bf
commit
8346e465f6
3 changed files with 11 additions and 9 deletions
|
@ -222,6 +222,7 @@ class CuraApplication(QtApplication):
|
|||
self._machine_error_checker = None
|
||||
|
||||
self._machine_settings_manager = MachineSettingsManager(self, parent = self)
|
||||
self._material_management_model = MaterialManagementModel()
|
||||
|
||||
self._discovered_printer_model = DiscoveredPrintersModel(self, parent = self)
|
||||
self._first_start_machine_actions_model = FirstStartMachineActionsModel(self, parent = self)
|
||||
|
@ -976,6 +977,10 @@ class CuraApplication(QtApplication):
|
|||
def getMachineActionManager(self, *args):
|
||||
return self._machine_action_manager
|
||||
|
||||
@pyqtSlot(result = QObject)
|
||||
def getMaterialManagementModel(self):
|
||||
return self._material_management_model
|
||||
|
||||
def getSimpleModeSettingsManager(self, *args):
|
||||
if self._simple_mode_settings_manager is None:
|
||||
self._simple_mode_settings_manager = SimpleModeSettingsManager()
|
||||
|
@ -1055,7 +1060,7 @@ class CuraApplication(QtApplication):
|
|||
qmlRegisterType(GenericMaterialsModel, "Cura", 1, 0, "GenericMaterialsModel")
|
||||
qmlRegisterType(MaterialBrandsModel, "Cura", 1, 0, "MaterialBrandsModel")
|
||||
qmlRegisterType(QualityManagementModel, "Cura", 1, 0, "QualityManagementModel")
|
||||
qmlRegisterType(MaterialManagementModel, "Cura", 1, 5, "MaterialManagementModel")
|
||||
qmlRegisterSingletonType(MaterialManagementModel, "Cura", 1, 5, "MaterialManagementModel", self.getMaterialManagementModel)
|
||||
|
||||
qmlRegisterType(DiscoveredPrintersModel, "Cura", 1, 0, "DiscoveredPrintersModel")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue