Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/cura
diff options
context:
space:
mode:
authorJaime van Kessel <nallath@gmail.com>2016-10-27 15:26:43 +0300
committerJaime van Kessel <nallath@gmail.com>2016-10-27 15:26:43 +0300
commit1aa71d6171304223be3f361508271b1493af5f09 (patch)
tree79fb2416908413bf112c34e95a8ac3ee99b91780 /cura
parent4a5d7cbc739132f654c5710634af02690dbbae93 (diff)
Profiles model is now a singleton, to prevent the agressive garbage collecting to break stuff
CURA-2826
Diffstat (limited to 'cura')
-rw-r--r--cura/CuraApplication.py2
-rw-r--r--cura/Settings/ProfilesModel.py15
2 files changed, 16 insertions, 1 deletions
diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py
index ec52c7aea1..3a67b9b95c 100644
--- a/cura/CuraApplication.py
+++ b/cura/CuraApplication.py
@@ -549,7 +549,7 @@ class CuraApplication(QtApplication):
qmlRegisterType(cura.Settings.ExtrudersModel, "Cura", 1, 0, "ExtrudersModel")
qmlRegisterType(cura.Settings.ContainerSettingsModel, "Cura", 1, 0, "ContainerSettingsModel")
- qmlRegisterType(cura.Settings.ProfilesModel, "Cura", 1, 0, "ProfilesModel")
+ qmlRegisterSingletonType(cura.Settings.ProfilesModel, "Cura", 1, 0, "ProfilesModel", cura.Settings.ProfilesModel.createProfilesModel)
qmlRegisterType(cura.Settings.QualityAndUserProfilesModel, "Cura", 1, 0, "QualityAndUserProfilesModel")
qmlRegisterType(cura.Settings.UserProfilesModel, "Cura", 1, 0, "UserProfilesModel")
qmlRegisterType(cura.Settings.MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler")
diff --git a/cura/Settings/ProfilesModel.py b/cura/Settings/ProfilesModel.py
index 2ad9813e37..c03e074053 100644
--- a/cura/Settings/ProfilesModel.py
+++ b/cura/Settings/ProfilesModel.py
@@ -25,6 +25,21 @@ class ProfilesModel(InstanceContainersModel):
Application.getInstance().getMachineManager().activeStackChanged.connect(self._update)
Application.getInstance().getMachineManager().activeMaterialChanged.connect(self._update)
+ # Factory function, used by QML
+ @staticmethod
+ def createProfilesModel(engine, js_engine):
+ return ProfilesModel.getInstance()
+
+ ## Get the singleton instance for this class.
+ @classmethod
+ def getInstance(cls):
+ # Note: Explicit use of class name to prevent issues with inheritance.
+ if ProfilesModel.__instance is None:
+ ProfilesModel.__instance = cls()
+ return ProfilesModel.__instance
+
+ __instance = None
+
## Fetch the list of containers to display.
#
# See UM.Settings.Models.InstanceContainersModel._fetchInstanceContainers().