mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Make layer processing abort when starting slice
This involved adding an abort flag to the layer processing job, and making the job check back on that flag periodically. If processing a single layer takes forever then it will never stop the job at all, so it assumes that the concurrent programming in Python is Fair. Contributes to issue CURA-864.
This commit is contained in:
parent
c0d167e751
commit
63a8b96049
2 changed files with 35 additions and 3 deletions
|
@ -24,12 +24,26 @@ class ProcessSlicedObjectListJob(Job):
|
|||
self._message = message
|
||||
self._scene = Application.getInstance().getController().getScene()
|
||||
self._progress = None
|
||||
self._abortRequested = False
|
||||
|
||||
## Aborts the processing of layers.
|
||||
#
|
||||
# This abort is made on a best-effort basis, meaning that the actual
|
||||
# job thread will check once in a while to see whether an abort is
|
||||
# requested and then stop processing by itself. There is no guarantee
|
||||
# that the abort will stop the job any time soon or even at all.
|
||||
def abort(self):
|
||||
self._abortRequested = True
|
||||
|
||||
def run(self):
|
||||
if Application.getInstance().getController().getActiveView().getPluginId() == "LayerView":
|
||||
self._progress = Message(catalog.i18nc("@info:status", "Processing Layers"), 0, False, -1)
|
||||
self._progress.show()
|
||||
Job.yieldThread()
|
||||
if self._abortRequested:
|
||||
if self._progress:
|
||||
self._progress.hide()
|
||||
return
|
||||
|
||||
Application.getInstance().getController().activeViewChanged.connect(self._onActiveViewChanged)
|
||||
|
||||
|
@ -43,6 +57,10 @@ class ProcessSlicedObjectListJob(Job):
|
|||
else:
|
||||
object_id_map[id(node)] = node
|
||||
Job.yieldThread()
|
||||
if self._abortRequested:
|
||||
if self._progress:
|
||||
self._progress.hide()
|
||||
return
|
||||
|
||||
settings = Application.getInstance().getMachineManager().getWorkingProfile()
|
||||
|
||||
|
@ -94,19 +112,28 @@ class ProcessSlicedObjectListJob(Job):
|
|||
# TODO: Rebuild the layer data mesh once the layer has been processed.
|
||||
# This needs some work in LayerData so we can add the new layers instead of recreating the entire mesh.
|
||||
|
||||
if self._abortRequested:
|
||||
if self._progress:
|
||||
self._progress.hide()
|
||||
return
|
||||
if self._progress:
|
||||
self._progress.setProgress(progress)
|
||||
|
||||
# We are done processing all the layers we got from the engine, now create a mesh out of the data
|
||||
layer_data.build()
|
||||
|
||||
if self._abortRequested:
|
||||
if self._progress:
|
||||
self._progress.hide()
|
||||
return
|
||||
|
||||
#Add layerdata decorator to scene node to indicate that the node has layerdata
|
||||
decorator = LayerDataDecorator.LayerDataDecorator()
|
||||
decorator.setLayerData(layer_data)
|
||||
new_node.addDecorator(decorator)
|
||||
|
||||
new_node.setMeshData(mesh)
|
||||
new_node.setParent(self._scene.getRoot())
|
||||
new_node.setParent(self._scene.getRoot()) #Note: After this we can no longer abort!
|
||||
|
||||
if self._progress:
|
||||
self._progress.setProgress(100)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue