mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 08:17:49 -06:00
Emit metaDataChanged when changing properties
Properties is a dictionary inside the metadata dictionary. If you change one of the properties, it'll check afterwards if the dictionary is different from what it was before, but since the dictionary is passed by reference all the time, it'll think that the dictionary didn't change: The reference is still the same, so the thing it checks against is updated along. This solution is a bit ugly but it does notice when the metadata changed inside the properties and then emits a change signal. Contributes to issue CURA-2822.
This commit is contained in:
parent
c7120dddda
commit
8ae49c317c
1 changed files with 5 additions and 0 deletions
|
@ -218,6 +218,7 @@ class ContainerManager(QObject):
|
|||
entries = entry_name.split("/")
|
||||
entry_name = entries.pop()
|
||||
|
||||
sub_item_changed = False
|
||||
if entries:
|
||||
root_name = entries.pop(0)
|
||||
root = container.getMetaDataEntry(root_name)
|
||||
|
@ -226,12 +227,16 @@ class ContainerManager(QObject):
|
|||
for entry in entries:
|
||||
item = item.get(entries.pop(0), { })
|
||||
|
||||
if item[entry_name] != entry_value:
|
||||
sub_item_changed = True
|
||||
item[entry_name] = entry_value
|
||||
|
||||
entry_name = root_name
|
||||
entry_value = root
|
||||
|
||||
container.setMetaDataEntry(entry_name, entry_value)
|
||||
if sub_item_changed: #If it was only a sub-item that has changed then the setMetaDataEntry won't correctly notice that something changed, and we must manually signal that the metadata changed.
|
||||
container.metaDataChanged.emit(container)
|
||||
|
||||
return True
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue