From c6ca132e6e640326adf22f64e1363f2d53c823b7 Mon Sep 17 00:00:00 2001 From: Suzanne Soy Date: Sun, 3 Oct 2021 00:22:32 +0100 Subject: [PATCH] Circumvent segfault when reloading list of tools; displaying a dialog box and clearing the focus seems to do the trick, probably some part of the old list of tools was in use and got replaced before being cleaned up properly. --- SearchTools.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/SearchTools.py b/SearchTools.py index 2c282b4..ca21ef9 100644 --- a/SearchTools.py +++ b/SearchTools.py @@ -21,7 +21,7 @@ OK Optimize so that it's not so slow OK speed up startup to show the box instantly and do the slow loading on first click. OK One small bug: when the 3D view is initialized, it causes a loss of focus on the drop-down. We restore it, but the currently-selected index is left unchanged, so the down or up arrow has to be pressed twice. * split into several files, try to keep the absolute minimum of code possible in the main file to speed up startup -* segfault when reloading +OK segfault when reloading """ ################################"" @@ -106,7 +106,14 @@ def iconToHTML(icon, sz = 12, mode = QtGui.QIcon.Mode.Normal, state = QtGui.QIco return '' def refreshToolsAction(act): print('Refresh list of tools') - refreshToolbars() + fw = QtGui.QApplication.focusWidget() + if fw is not None: + fw.clearFocus() + reply = QtGui.QMessageBox.question(None, "Load all workbenches?", "Load all workbenches? This can cause FreeCAD to become unstable, and this \"reload tools\" feature contained a bug that crashed freecad systematically, so please make sure you save your work before. It's a good idea to restart FreeCAD after this operation.", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) + if reply == QtGui.QMessageBox.Yes: + refreshToolbars() + else: + print('cancelled') def toolbarAction(act): print('show toolbar ' + act['toolbar'] + ' from workbenches ' + repr(act['workbenches'])) def subToolAction(act):