mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Make extra sure cache is emptied when objects get altered.
See the (new) cachePerInstance decorator in UM/Decorators, and the accompanying CachedMemberFunction handler-class. part of CURA-11761
This commit is contained in:
parent
f8aa923ce0
commit
d0252554c4
3 changed files with 10 additions and 2 deletions
|
@ -11,6 +11,7 @@ import xml.etree.ElementTree as ET
|
|||
from UM.PluginRegistry import PluginRegistry
|
||||
from UM.Resources import Resources
|
||||
from UM.Logger import Logger
|
||||
from UM.Decorators import CachedMemberFunctions
|
||||
import UM.Dictionary
|
||||
from UM.Settings.InstanceContainer import InstanceContainer
|
||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||
|
@ -71,6 +72,8 @@ class XmlMaterialProfile(InstanceContainer):
|
|||
Logger.log("w", "Can't change metadata {key} of material {material_id} because it's read-only.".format(key = key, material_id = self.getId()))
|
||||
return
|
||||
|
||||
CachedMemberFunctions.clearInstanceCache(self)
|
||||
|
||||
# Some metadata such as diameter should also be instantiated to be a setting. Go though all values for the
|
||||
# "properties" field and apply the new values to SettingInstances as well.
|
||||
new_setting_values_dict = {}
|
||||
|
@ -480,6 +483,7 @@ class XmlMaterialProfile(InstanceContainer):
|
|||
first.append(element)
|
||||
|
||||
def clearData(self):
|
||||
CachedMemberFunctions.clearInstanceCache(self)
|
||||
self._metadata = {
|
||||
"id": self.getId(),
|
||||
"name": ""
|
||||
|
@ -519,6 +523,8 @@ class XmlMaterialProfile(InstanceContainer):
|
|||
def deserialize(self, serialized, file_name = None):
|
||||
"""Overridden from InstanceContainer"""
|
||||
|
||||
CachedMemberFunctions.clearInstanceCache(self)
|
||||
|
||||
containers_to_add = []
|
||||
# update the serialized data first
|
||||
from UM.Settings.Interfaces import ContainerInterface
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue