Merge branch 'master' into CS-278_ignore_material_empty

* master:
  Do not trigger slicing if there's no slicable object
  Fix regex in FlavorParser
This commit is contained in:
ChrisTerBeke 2019-09-03 21:30:34 +02:00
commit abb1d5d5eb
No known key found for this signature in database
GPG Key ID: A49F1AB9D7E0C263
2 changed files with 14 additions and 6 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:
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)
def _clearLayerData(self, build_plate_numbers: Set = None) -> None:
# 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
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.stopSlicing()
self.markSliceAll()

View File

@ -68,7 +68,7 @@ class FlavorParser:
if n < 0:
return None
n += len(code)
pattern = re.compile("[;\s]")
pattern = re.compile("[;\\s]")
match = pattern.search(line, n)
m = match.start() if match is not None else -1
try:
@ -476,11 +476,6 @@ class FlavorParser:
machine_depth = global_stack.getProperty("machine_depth", "value")
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")
if CuraApplication.getInstance().getPreferences().getValue("gcodereader/show_caution"):