Change definition ID upon reading profile

Implements CURA-6713.
This commit is contained in:
Ghostkeeper 2019-09-03 15:38:41 +02:00
parent c41af1b9a0
commit 2f917c2841
No known key found for this signature in database
GPG Key ID: 86BEF881AE2CF276
2 changed files with 9 additions and 6 deletions

View File

@ -241,12 +241,11 @@ class CuraContainerRegistry(ContainerRegistry):
# And check if the profile_definition matches either one (showing error if not): # And check if the profile_definition matches either one (showing error if not):
if profile_definition != expected_machine_definition: if profile_definition != expected_machine_definition:
Logger.log("e", "Profile [%s] is for machine [%s] but the current active machine is [%s]. Will not import the profile", file_name, profile_definition, expected_machine_definition) Logger.log("d", "Profile {file_name} is for machine {profile_definition}, but the current active machine is {expected_machine_definition}. Changing profile's definition.".format(file_name = file_name, profile_definition = profile_definition, expected_machine_definition = expected_machine_definition))
return { "status": "error",
"message": catalog.i18nc("@info:status Don't translate the XML tags <filename>!", "The machine defined in profile <filename>{0}</filename> ({1}) doesn't match with your current machine ({2}), could not import it.", file_name, profile_definition, expected_machine_definition)}
# Fix the global quality profile's definition field in case it's not correct
global_profile.setMetaDataEntry("definition", expected_machine_definition) global_profile.setMetaDataEntry("definition", expected_machine_definition)
for extruder_profile in extruder_profiles:
extruder_profile.setMetaDataEntry("definition", expected_machine_definition)
quality_name = global_profile.getName() quality_name = global_profile.getName()
quality_type = global_profile.getMetaDataEntry("quality_type") quality_type = global_profile.getMetaDataEntry("quality_type")

View File

@ -4,11 +4,11 @@
import configparser import configparser
from typing import List, Optional, Tuple from typing import List, Optional, Tuple
from UM.PluginRegistry import PluginRegistry
from UM.Logger import Logger from UM.Logger import Logger
from UM.Settings.ContainerFormatError import ContainerFormatError from UM.Settings.ContainerFormatError import ContainerFormatError
from UM.Settings.InstanceContainer import InstanceContainer # The new profile to make. from UM.Settings.InstanceContainer import InstanceContainer # The new profile to make.
from cura.CuraApplication import CuraApplication from cura.CuraApplication import CuraApplication
from cura.Machines.QualityManager import getMachineDefinitionIDForQualitySearch
from cura.ReaderWriters.ProfileReader import ProfileReader from cura.ReaderWriters.ProfileReader import ProfileReader
import zipfile import zipfile
@ -92,6 +92,10 @@ class CuraProfileReader(ProfileReader):
except Exception as e: except Exception as e:
Logger.log("e", "Error while trying to parse profile: %s", str(e)) Logger.log("e", "Error while trying to parse profile: %s", str(e))
return None return None
active_quality_definition = getMachineDefinitionIDForQualitySearch(CuraApplication.getInstance().getGlobalContainerStack().definition)
if profile.getMetaDataEntry("definition") != active_quality_definition:
profile.setMetaDataEntry("definition", active_quality_definition)
return profile return profile
## Upgrade a serialized profile to the current profile format. ## Upgrade a serialized profile to the current profile format.