diff --git a/UM/Settings/DefinitionContainer.py b/UM/Settings/DefinitionContainer.py index c1e6440fa..261cae82c 100644 --- a/UM/Settings/DefinitionContainer.py +++ b/UM/Settings/DefinitionContainer.py @@ -581,3 +581,6 @@ def __str__(self) -> str: def __repr__(self) -> str: return str(self) + + def __hash__(self) -> int: + return hash(self.getId()) diff --git a/UM/Settings/SettingDefinition.py b/UM/Settings/SettingDefinition.py index 69458b919..555f24ea2 100644 --- a/UM/Settings/SettingDefinition.py +++ b/UM/Settings/SettingDefinition.py @@ -153,7 +153,7 @@ def __setattr__(self, name: str, value: Any) -> None: def __hash__(self): """Ensure that the SettingDefinition is hashable, so it can be used in a set.""" - return hash(str(self)) + return hash((id(self), self._key, self._container)) def __getstate__(self): """For Pickle support. diff --git a/UM/Settings/SettingRelation.py b/UM/Settings/SettingRelation.py index e6e1a579d..a574ffd74 100644 --- a/UM/Settings/SettingRelation.py +++ b/UM/Settings/SettingRelation.py @@ -43,10 +43,10 @@ def __init__(self, owner: SettingDefinition, target: SettingDefinition, relation self._type = relation_type self._role = role - def __hash__(self): + def __hash__(self) -> int: """Ensure that the SettingRelation is hashable, so it can be used in a set.""" - return hash(str(self)) + return hash((self._owner, self._target, self._type, self._role)) @property def owner(self) -> SettingDefinition: