Do not trigger slicing if there's no slicable object

CURA-6604
This commit is contained in:
Lipu Fei 2019-09-03 20:01:10 +02:00
parent 09dc209956
commit 0524796145
2 changed files with 13 additions and 5 deletions

View file

@ -543,6 +543,15 @@ class CuraEngineBackend(QObject, Backend):
if error.getErrorCode() == Arcus.ErrorCode.BindFailedError and self._start_slice_job is not None: if error.getErrorCode() == Arcus.ErrorCode.BindFailedError and self._start_slice_job is not None:
self._start_slice_job.setIsCancelled(False) self._start_slice_job.setIsCancelled(False)
# Check if there's any slicable object in the scene.
def hasSlicableObject(self) -> bool:
has_slicable = False
for node in DepthFirstIterator(self._scene.getRoot()):
if node.callDecoration("isSliceable"):
has_slicable = True
break
return has_slicable
## Remove old layer data (if any) ## Remove old layer data (if any)
def _clearLayerData(self, build_plate_numbers: Set = None) -> None: def _clearLayerData(self, build_plate_numbers: Set = None) -> None:
# Clear out any old gcode # Clear out any old gcode
@ -561,6 +570,10 @@ class CuraEngineBackend(QObject, Backend):
## Convenient function: mark everything to slice, emit state and clear layer data ## Convenient function: mark everything to slice, emit state and clear layer data
def needsSlicing(self) -> None: def needsSlicing(self) -> None:
# CURA-6604: If there's no slicable object, do not (try to) trigger slice, which will clear all the current
# gcode. This can break Gcode file loading if it tries to remove it afterwards.
if not self.hasSlicableObject():
return
self.determineAutoSlicing() self.determineAutoSlicing()
self.stopSlicing() self.stopSlicing()
self.markSliceAll() self.markSliceAll()

View file

@ -476,11 +476,6 @@ class FlavorParser:
machine_depth = global_stack.getProperty("machine_depth", "value") machine_depth = global_stack.getProperty("machine_depth", "value")
scene_node.setPosition(Vector(-machine_width / 2, 0, machine_depth / 2)) scene_node.setPosition(Vector(-machine_width / 2, 0, machine_depth / 2))
# Make sure that all seen extruders (if exist in the currently active machine) are enabled.
for extruder_nr in self._extruders_seen:
if str(extruder_nr) in global_stack.extruders:
CuraApplication.getInstance().getMachineManager().setExtruderEnabled(extruder_nr, True)
Logger.log("d", "GCode loading finished") Logger.log("d", "GCode loading finished")
if CuraApplication.getInstance().getPreferences().getValue("gcodereader/show_caution"): if CuraApplication.getInstance().getPreferences().getValue("gcodereader/show_caution"):