From 8ae49c317cbd317cf96a0f90c7a7f37e23a4904d Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 29 Jun 2017 15:03:49 +0200 Subject: [PATCH] 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. --- cura/Settings/ContainerManager.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cura/Settings/ContainerManager.py b/cura/Settings/ContainerManager.py index 9a2282c8c0..aee9eccdd7 100644 --- a/cura/Settings/ContainerManager.py +++ b/cura/Settings/ContainerManager.py @@ -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