Fixed error spam on progress sliced layer run

CURA-4349
This commit is contained in:
Jaime van Kessel 2017-09-26 09:30:49 +02:00
parent 355aa36bb4
commit 583b776c6c

View file

@ -47,7 +47,7 @@ class ProcessSlicedLayersJob(Job):
super().__init__()
self._layers = layers
self._scene = Application.getInstance().getController().getScene()
self._progress = None
self._progress_message = Message(catalog.i18nc("@info:status", "Processing Layers"), 0, False, -1)
self._abort_requested = False
## Aborts the processing of layers.
@ -62,12 +62,11 @@ class ProcessSlicedLayersJob(Job):
def run(self):
start_time = time()
if Application.getInstance().getController().getActiveView().getPluginId() == "LayerView":
self._progress = Message(catalog.i18nc("@info:status", "Processing Layers"), 0, False, -1)
self._progress.show()
self._progress_message.show()
Job.yieldThread()
if self._abort_requested:
if self._progress:
self._progress.hide()
if self._progress_message:
self._progress_message.hide()
return
Application.getInstance().getController().activeViewChanged.connect(self._onActiveViewChanged)
@ -80,8 +79,8 @@ class ProcessSlicedLayersJob(Job):
node.getParent().removeChild(node)
break
if self._abort_requested:
if self._progress:
self._progress.hide()
if self._progress_message:
self._progress_message.hide()
return
# Force garbage collection.
@ -159,11 +158,11 @@ class ProcessSlicedLayersJob(Job):
# This needs some work in LayerData so we can add the new layers instead of recreating the entire mesh.
if self._abort_requested:
if self._progress:
self._progress.hide()
if self._progress_message:
self._progress_message.hide()
return
if self._progress:
self._progress.setProgress(progress)
if self._progress_message:
self._progress_message.setProgress(progress)
# We are done processing all the layers we got from the engine, now create a mesh out of the data
@ -197,8 +196,8 @@ class ProcessSlicedLayersJob(Job):
layer_mesh = layer_data.build(material_color_map, line_type_brightness)
if self._abort_requested:
if self._progress:
self._progress.hide()
if self._progress_message:
self._progress_message.hide()
return
# Add LayerDataDecorator to scene node to indicate that the node has layer data
@ -216,15 +215,15 @@ class ProcessSlicedLayersJob(Job):
if not settings.getProperty("machine_center_is_zero", "value"):
new_node.setPosition(Vector(-settings.getProperty("machine_width", "value") / 2, 0.0, settings.getProperty("machine_depth", "value") / 2))
if self._progress:
self._progress.setProgress(100)
if self._progress_message:
self._progress_message.setProgress(100)
view = Application.getInstance().getController().getActiveView()
if view.getPluginId() == "LayerView":
view.resetLayerData()
if self._progress:
self._progress.hide()
if self._progress_message:
self._progress_message.hide()
# Clear the unparsed layers. This saves us a bunch of memory if the Job does not get destroyed.
self._layers = None
@ -234,10 +233,10 @@ class ProcessSlicedLayersJob(Job):
def _onActiveViewChanged(self):
if self.isRunning():
if Application.getInstance().getController().getActiveView().getPluginId() == "LayerView":
if not self._progress:
self._progress = Message(catalog.i18nc("@info:status", "Processing Layers"), 0, False, 0, catalog.i18nc("@info:title", "Information"))
if self._progress.getProgress() != 100:
self._progress.show()
if not self._progress_message:
self._progress_message = Message(catalog.i18nc("@info:status", "Processing Layers"), 0, False, 0, catalog.i18nc("@info:title", "Information"))
if self._progress_message.getProgress() != 100:
self._progress_message.show()
else:
if self._progress:
self._progress.hide()
if self._progress_message:
self._progress_message.hide()