mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 02:55:57 +08:00
Ensure that profiles are cleaned up if one of the set is incorrect
This commit is contained in:
parent
872d6365a9
commit
f5f91c9c3a
@ -292,6 +292,7 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
profile_or_list.append(profile)
|
profile_or_list.append(profile)
|
||||||
|
|
||||||
# Import all profiles
|
# Import all profiles
|
||||||
|
profile_ids_added = [] # type: List[str]
|
||||||
for profile_index, profile in enumerate(profile_or_list):
|
for profile_index, profile in enumerate(profile_or_list):
|
||||||
if profile_index == 0:
|
if profile_index == 0:
|
||||||
# This is assumed to be the global profile
|
# This is assumed to be the global profile
|
||||||
@ -312,11 +313,15 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
|
|
||||||
result = self._configureProfile(profile, profile_id, new_name, expected_machine_definition)
|
result = self._configureProfile(profile, profile_id, new_name, expected_machine_definition)
|
||||||
if result is not None:
|
if result is not None:
|
||||||
|
# Remove any profiles that did got added.
|
||||||
|
for profile_id in profile_ids_added:
|
||||||
|
self.removeContainer(profile_id)
|
||||||
|
|
||||||
return {"status": "error", "message": catalog.i18nc(
|
return {"status": "error", "message": catalog.i18nc(
|
||||||
"@info:status Don't translate the XML tag <filename>!",
|
"@info:status Don't translate the XML tag <filename>!",
|
||||||
"Failed to import profile from <filename>{0}</filename>:",
|
"Failed to import profile from <filename>{0}</filename>:",
|
||||||
file_name) + " " + result}
|
file_name) + " " + result}
|
||||||
|
profile_ids_added.append(profile.getId())
|
||||||
return {"status": "ok", "message": catalog.i18nc("@info:status", "Successfully imported profile {0}", profile_or_list[0].getName())}
|
return {"status": "ok", "message": catalog.i18nc("@info:status", "Successfully imported profile {0}", profile_or_list[0].getName())}
|
||||||
|
|
||||||
# This message is throw when the profile reader doesn't find any profile in the file
|
# This message is throw when the profile reader doesn't find any profile in the file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user