Skip to content

Commit

Permalink
FEM: Make sure cursor gets restored if write_calculix_input_file fails
Browse files Browse the repository at this point in the history
Reported-by: wmayer
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
  • Loading branch information
PrzemoF authored and wwmayer committed Apr 17, 2015
1 parent d3c7270 commit 2d90d39
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Mod/Fem/MechanicalAnalysis.py
Expand Up @@ -232,7 +232,7 @@ def __init__(self,object):

#Connect Signals and Slots
QtCore.QObject.connect(self.form.toolButton_chooseOutputDir, QtCore.SIGNAL("clicked()"), self.chooseOutputDir)
QtCore.QObject.connect(self.form.pushButton_write, QtCore.SIGNAL("clicked()"), self.writeCalculixInputFile)
QtCore.QObject.connect(self.form.pushButton_write, QtCore.SIGNAL("clicked()"), self.write_input_file_handler)
QtCore.QObject.connect(self.form.pushButton_edit, QtCore.SIGNAL("clicked()"), self.editCalculixInputFile)
QtCore.QObject.connect(self.form.pushButton_generate, QtCore.SIGNAL("clicked()"), self.runCalculix)

Expand Down Expand Up @@ -339,7 +339,17 @@ def chooseOutputDir(self):
self.params.SetString("JobDir",str(dirname))
self.form.lineEdit_outputDir.setText(dirname)

def writeCalculixInputFile(self):
def write_input_file_handler(self):
QApplication.setOverrideCursor(Qt.WaitCursor)
try:
self.write_calculix_input_file()
except:
print "Unexpected error when writing CalculiX input file:", sys.exc_info()[0]
raise
finally:
QApplication.restoreOverrideCursor()

def write_calculix_input_file(self):
print 'writeCalculixInputFile'
self.Start = time.time()

Expand Down Expand Up @@ -390,8 +400,6 @@ def writeCalculixInputFile(self):
QtGui.QMessageBox.critical(None, "Missing prerequisite","No force-constraint nodes defined in the Analysis")
return

QApplication.setOverrideCursor(Qt.WaitCursor)

self.Basename = self.TempDir + '/' + MeshObject.Name
filename = self.Basename + '.inp'

Expand Down Expand Up @@ -551,8 +559,6 @@ def writeCalculixInputFile(self):
inpfile.close()
self.femConsoleMessage("Write completed.")

QApplication.restoreOverrideCursor()

def start_ext_editor(self, ext_editor_path, filename):
if not hasattr(self, "ext_editor_process"):
self.ext_editor_process = QtCore.QProcess()
Expand Down

0 comments on commit 2d90d39

Please sign in to comment.