Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey de l'Arago <joeydelarago@gmail.com>2022-09-23 11:32:03 +0300
committerJoey de l'Arago <joeydelarago@gmail.com>2022-09-23 11:32:03 +0300
commitc729b87f3ccd9cfddd6269a234bc23516038db93 (patch)
treeaa011894677e8d68e0effac696a12f130779164a
parentecf38b23bd778f85d9ba1558945df3a89523e4e2 (diff)
Duplicate print jobs were being sent when printing via cloud from abstract printers.
This was due to the connect function not being called on the CloudOutputDevice used to print on the cloud. This function is only called when it becomes an active printer (AbstractCloudOutputDevice is the active printer instead now). The fix is to always listen for signals to reset the print job even when not the active printer. I've chosen different signals now so there is not too much spam on the reset function. The BackendStateDone signal catches new slices. The SceneChanged signal catches ufp files being loaded (These do not trigger BackendState changes) CURA-9678
-rw-r--r--plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py
index 4c58c82350..692a2af160 100644
--- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py
+++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py
@@ -10,7 +10,6 @@ from PyQt6.QtGui import QDesktopServices
from PyQt6.QtNetwork import QNetworkReply, QNetworkRequest # Parse errors specific to print job uploading.
from UM import i18nCatalog
-from UM.Backend.Backend import BackendState
from UM.FileHandler.FileHandler import FileHandler
from UM.Logger import Logger
from UM.Scene.SceneNode import SceneNode
@@ -18,6 +17,8 @@ from UM.Version import Version
from cura.CuraApplication import CuraApplication
from cura.PrinterOutput.NetworkedPrinterOutputDevice import AuthState
from cura.PrinterOutput.PrinterOutputDevice import ConnectionType
+from cura.Scene.GCodeListDecorator import GCodeListDecorator
+from cura.Scene.SliceableObjectDecorator import SliceableObjectDecorator
from .CloudApiClient import CloudApiClient
from ..ExportFileJob import ExportFileJob
@@ -110,6 +111,9 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
self._pre_upload_print_job = None # type: Optional[CloudPrintJobResponse]
self._uploaded_print_job = None # type: Optional[CloudPrintJobResponse]
+ CuraApplication.getInstance().getBackend().backendDone.connect(self._resetPrintJob)
+ CuraApplication.getInstance().getController().getScene().sceneChanged.connect(self._onSceneChanged)
+
def connect(self) -> None:
"""Connects this device."""
@@ -117,8 +121,6 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
return
Logger.log("i", "Attempting to connect to cluster %s", self.key)
super().connect()
-
- CuraApplication.getInstance().getBackend().backendStateChange.connect(self._onBackendStateChange)
self._update()
def disconnect(self) -> None:
@@ -128,11 +130,14 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
return
super().disconnect()
Logger.log("i", "Disconnected from cluster %s", self.key)
- CuraApplication.getInstance().getBackend().backendStateChange.disconnect(self._onBackendStateChange)
- def _onBackendStateChange(self, _: BackendState) -> None:
- """Resets the print job that was uploaded to force a new upload, runs whenever the user re-slices."""
+ def _onSceneChanged(self, node: SceneNode):
+ # This will reset the print job if a ufp file is loaded. This forces a new upload when printing via cloud from ufp.
+ if node.getDecorator(GCodeListDecorator) or node.getDecorator(SliceableObjectDecorator):
+ self._resetPrintJob()
+ def _resetPrintJob(self) -> None:
+ """Resets the print job that was uploaded to force a new upload, runs whenever slice finishes."""
self._tool_path = None
self._pre_upload_print_job = None
self._uploaded_print_job = None