flatCam crashes when saving Gcode
sometimes when I will save a newly generated CNC-Job, the Program crashes with the following message.
There must be a strange error in the if/elif cascade that tries to find out the value of the variable “flt“, missing default value is my guess
Traceback (most recent call last):
File "/Users/jens/Documents/Development/flatcam_work/flatcam/FlatCAMApp.py", line 9589, in <lambda>
self.source_editor_tab.buttonSave.clicked.connect(lambda: self.source_editor_tab.handleSaveGCode(filt=flt))
NameError: free variable 'flt' referenced before assignment in enclosing scope
Abort trap: 6
Comments (3)
-
reporter -
Thank you for the report . It may be that the lambda may expect to take a parameter that is after that passed as parameter to the self.source_editor_tab.handleSaveGCode method. I don’t like to modify that since the clicked signal also pass away a parameter of it’s own and I don’t need it.
In any case, for now I’ve changed the ‘if - elif' chain, took out the ‘else’ section and made the assignment before the if…
Something like this.
From:if obj.kind == 'gerber': flt = "Gerber Files (*.GBR);;All Files (*.*)" elif obj.kind == 'excellon': flt = "Excellon Files (*.DRL);;All Files (*.*)" elif obj.kind == 'cncjob': "GCode Files (*.NC);;All Files (*.*)" else: flt = "All Files (*.*)"
to:
flt = "All Files (*.*)" if obj.kind == 'gerber': flt = "Gerber Files (*.GBR);;All Files (*.*)" elif obj.kind == 'excellon': flt = "Excellon Files (*.DRL);;All Files (*.*)" elif obj.kind == 'cncjob': "GCode Files (*.NC);;All Files (*.*)"
This way, Python gets what it wants, an initial declaration of that object, flt, maintaining the logic.
-
- changed status to resolved
Fix will be available in beta version 8.99.
- Log in to comment
Additional Detail : Only occures if will you press the save button within the source-editor