mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 03:06:00 +08:00
Specialise _isMetadataValid for Cura to check setting_version
Because we need to reject loading metadata for containers whose setting_version is incorrect. Contributes to issue CURA-6270.
This commit is contained in:
parent
20fc26b8ba
commit
3c779b58de
@ -1,11 +1,11 @@
|
||||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import os
|
||||
import re
|
||||
import configparser
|
||||
|
||||
from typing import cast, Dict, Optional
|
||||
from typing import Any, cast, Dict, Optional
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
|
||||
from UM.Decorators import override
|
||||
@ -327,6 +327,23 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||
self._registerSingleExtrusionMachinesExtruderStacks()
|
||||
self._connectUpgradedExtruderStacksToMachines()
|
||||
|
||||
## Check if the metadata for a container is okay before adding it.
|
||||
#
|
||||
# This overrides the one from UM.Settings.ContainerRegistry because we
|
||||
# also require that the setting_version is correct.
|
||||
@override(ContainerRegistry)
|
||||
def _isMetadataValid(self, metadata: Optional[Dict[str, Any]]) -> bool:
|
||||
if metadata is None:
|
||||
return False
|
||||
if "setting_version" not in metadata:
|
||||
return False
|
||||
try:
|
||||
if int(metadata["setting_version"]) != cura.CuraApplication.CuraApplication.SettingVersion:
|
||||
return False
|
||||
except ValueError: #Not parsable as int.
|
||||
return False
|
||||
return True
|
||||
|
||||
## Update an imported profile to match the current machine configuration.
|
||||
#
|
||||
# \param profile The profile to configure.
|
||||
|
Loading…
x
Reference in New Issue
Block a user