mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-20 12:39:06 +08:00
Profiles model is now a singleton, to prevent the agressive garbage collecting to break stuff
CURA-2826
This commit is contained in:
parent
4a5d7cbc73
commit
1aa71d6171
@ -549,7 +549,7 @@ class CuraApplication(QtApplication):
|
|||||||
qmlRegisterType(cura.Settings.ExtrudersModel, "Cura", 1, 0, "ExtrudersModel")
|
qmlRegisterType(cura.Settings.ExtrudersModel, "Cura", 1, 0, "ExtrudersModel")
|
||||||
|
|
||||||
qmlRegisterType(cura.Settings.ContainerSettingsModel, "Cura", 1, 0, "ContainerSettingsModel")
|
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.QualityAndUserProfilesModel, "Cura", 1, 0, "QualityAndUserProfilesModel")
|
||||||
qmlRegisterType(cura.Settings.UserProfilesModel, "Cura", 1, 0, "UserProfilesModel")
|
qmlRegisterType(cura.Settings.UserProfilesModel, "Cura", 1, 0, "UserProfilesModel")
|
||||||
qmlRegisterType(cura.Settings.MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler")
|
qmlRegisterType(cura.Settings.MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler")
|
||||||
|
@ -25,6 +25,21 @@ class ProfilesModel(InstanceContainersModel):
|
|||||||
Application.getInstance().getMachineManager().activeStackChanged.connect(self._update)
|
Application.getInstance().getMachineManager().activeStackChanged.connect(self._update)
|
||||||
Application.getInstance().getMachineManager().activeMaterialChanged.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.
|
## Fetch the list of containers to display.
|
||||||
#
|
#
|
||||||
# See UM.Settings.Models.InstanceContainersModel._fetchInstanceContainers().
|
# See UM.Settings.Models.InstanceContainersModel._fetchInstanceContainers().
|
||||||
|
@ -13,7 +13,7 @@ Menu
|
|||||||
|
|
||||||
Instantiator
|
Instantiator
|
||||||
{
|
{
|
||||||
model: Cura.ProfilesModel { }
|
model: Cura.ProfilesModel
|
||||||
|
|
||||||
MenuItem
|
MenuItem
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user