Give a warning when you can't update metadata because it's read-only

This bit me in the bum today.
This commit is contained in:
Ghostkeeper 2019-02-14 13:26:20 +01:00
parent 0a325426d0
commit e2a7a68883
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -1,4 +1,4 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
import copy import copy
@ -60,6 +60,7 @@ class XmlMaterialProfile(InstanceContainer):
def setMetaDataEntry(self, key, value, apply_to_all = True): def setMetaDataEntry(self, key, value, apply_to_all = True):
registry = ContainerRegistry.getInstance() registry = ContainerRegistry.getInstance()
if registry.isReadOnly(self.getId()): if registry.isReadOnly(self.getId()):
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 return
# Prevent recursion # Prevent recursion
@ -121,6 +122,8 @@ class XmlMaterialProfile(InstanceContainer):
registry = ContainerRegistry.getInstance() registry = ContainerRegistry.getInstance()
base_file = self.getMetaDataEntry("base_file", "") base_file = self.getMetaDataEntry("base_file", "")
print("--------base_file:", base_file)
print("--------metadata:", self._metadata)
if base_file and self.getId() != base_file: if base_file and self.getId() != base_file:
# Since we create an instance of XmlMaterialProfile for each machine and nozzle in the profile, # Since we create an instance of XmlMaterialProfile for each machine and nozzle in the profile,
# we should only serialize the "base" material definition, since that can then take care of # we should only serialize the "base" material definition, since that can then take care of