Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CURA-11761] Make extra sure cache is emptied when objects get altered. #19611

Merged
merged 4 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cura/Settings/CuraContainerStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from PyQt6.QtCore import pyqtProperty, pyqtSignal, QObject

from UM.Application import Application
from UM.Decorators import override
from UM.Decorators import CachedMemberFunctions, override
from UM.FlameProfiler import pyqtSlot
from UM.Logger import Logger
from UM.Settings.ContainerStack import ContainerStack, InvalidContainerStackError
Expand Down Expand Up @@ -237,6 +237,7 @@ def setProperty(self, key: str, property_name: str, property_value: Any, contain
:param new_value: The new value to set the property to.
"""

CachedMemberFunctions.clearInstanceCache(self)
container_index = _ContainerIndexes.UserChanges
self._containers[container_index].setProperty(key, property_name, property_value, container, set_from_cache)

Expand Down
3 changes: 2 additions & 1 deletion cura/Settings/ExtruderStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from PyQt6.QtCore import pyqtProperty, pyqtSignal

from UM.Decorators import override
from UM.Decorators import CachedMemberFunctions, override
from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
from UM.Settings.ContainerStack import ContainerStack
from UM.Settings.ContainerRegistry import ContainerRegistry
Expand Down Expand Up @@ -86,6 +86,7 @@ def getCompatibleMaterialDiameter(self) -> float:
def setCompatibleMaterialDiameter(self, value: float) -> None:
old_approximate_diameter = self.getApproximateMaterialDiameter()
if self.getCompatibleMaterialDiameter() != value:
CachedMemberFunctions.clearInstanceCache(self)
self.definitionChanges.setProperty("material_diameter", "value", value)
self.compatibleMaterialDiameterChanged.emit()

Expand Down
6 changes: 6 additions & 0 deletions plugins/XmlMaterialProfile/XmlMaterialProfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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
Expand Down Expand Up @@ -71,6 +72,8 @@ def setMetaDataEntry(self, key, value, apply_to_all = True):
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 = {}
Expand Down Expand Up @@ -480,6 +483,7 @@ def _combineElement(first, second):
first.append(element)

def clearData(self):
CachedMemberFunctions.clearInstanceCache(self)
self._metadata = {
"id": self.getId(),
"name": ""
Expand Down Expand Up @@ -519,6 +523,8 @@ def getMetadataFromSerialized(cls, serialized: str, property_name: str) -> str:
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
Expand Down
Loading