From 4fa51484d183852b4093c9a6f06171c8f1b23e3a Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Tue, 19 Feb 2013 13:56:55 +0000
Subject: [PATCH] fix crash (when deleting widget with focus and pending
 callback; make sure the tree gets the focus before we delete all the
 children)

---
 Fltk/onelabGroup.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Fltk/onelabGroup.cpp b/Fltk/onelabGroup.cpp
index d02697ce01..e094d329c7 100644
--- a/Fltk/onelabGroup.cpp
+++ b/Fltk/onelabGroup.cpp
@@ -1074,6 +1074,7 @@ Fl_Widget *onelabGroup::_addParameterWidget(onelab::number &p, Fl_Tree_Item *n,
   // check box (boolean choice)
   if(p.getChoices().size() == 2 &&
      p.getChoices()[0] == 0 && p.getChoices()[1] == 1){
+    n->labelsize(FL_NORMAL_SIZE + 2);
     Fl_Check_Button *but = new Fl_Check_Button(1, 1, 2 * ww, 1);
     but->box(FL_FLAT_BOX);
     but->color(_tree->color());
@@ -1337,6 +1338,8 @@ void onelabGroup::rebuildTree()
 
   std::set<std::string> closed = _getClosedGmshMenus();
 
+  _tree->take_focus(); // make sure we remove the focus from any widget that
+                       // will be deleted; this can crash fltk
   _tree->clear();
   _tree->sortorder(FL_TREE_SORT_ASCENDING);
   _tree->selectmode(FL_TREE_SELECT_NONE);
-- 
GitLab