CURA-4870 Update the names of the groups in the container stacks when

there is temporary name after upgrading from 3.2
This commit is contained in:
Diego Prado Gesto 2018-03-15 14:44:01 +01:00
parent c21b19a910
commit cbe929242e
2 changed files with 16 additions and 2 deletions

View file

@ -3,6 +3,7 @@
from UM.Application import Application
from UM.Logger import Logger
from UM.Settings.ContainerRegistry import ContainerRegistry
from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionState
@ -254,6 +255,21 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
self._last_manager_create_time = time()
self._manager.authenticationRequired.connect(self._onAuthenticationRequired)
self._checkCorrectGroupName()
## This method checks if the name of the group stored in the definition container is correct.
# After updating from 3.2 to 3.3 some group names may be temporary. If there is a mismatch in the name of the group
# then all the container stacks are updated, both the current and the hidden ones.
def _checkCorrectGroupName(self):
global_container_stack = Application.getInstance().getGlobalContainerStack()
if global_container_stack and self.getId() == global_container_stack.getMetaDataEntry("um_network_key"):
# Check if the connect_group_name is correct. If not, update all the containers connected to the same printer
if global_container_stack.getMetaDataEntry("connect_group_name") != self.name:
metadata_filter = {"um_network_key": global_container_stack.getMetaDataEntry("um_network_key")}
hidden_containers = ContainerRegistry.getInstance().findContainerStacks(type = "machine", **metadata_filter)
for container in hidden_containers:
container.setMetaDataEntry("connect_group_name", self.name)
def _registerOnFinishedCallback(self, reply: QNetworkReply, onFinished: Optional[Callable[[Any, QNetworkReply], None]]) -> None:
if onFinished is not None:
self._onFinishedCallbacks[reply.url().toString() + str(reply.operation())] = onFinished

View file

@ -10,7 +10,6 @@ from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
from UM.Signal import Signal
from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal, QTimer
import UM.FlameProfiler
from UM.FlameProfiler import pyqtSlot
from UM import Util
@ -24,7 +23,6 @@ from UM.Settings.SettingFunction import SettingFunction
from UM.Signal import postponeSignals, CompressTechnique
from cura.Machines.QualityManager import getMachineDefinitionIDForQualitySearch
from cura.Machines.VariantManager import VariantType
from cura.PrinterOutputDevice import PrinterOutputDevice
from cura.PrinterOutput.ConfigurationModel import ConfigurationModel
from cura.PrinterOutput.ExtruderConfigurationModel import ExtruderConfigurationModel