From cda67987f6df3f09f5218adcd87dcdaf6d27fa75 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Tue, 20 Dec 2016 12:30:11 +0000 Subject: [PATCH] don't crash when trying to re-add an existing item in the tree --- Fltk/onelabGroup.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Fltk/onelabGroup.cpp b/Fltk/onelabGroup.cpp index 00183f2600..f0d2f72e2c 100644 --- a/Fltk/onelabGroup.cpp +++ b/Fltk/onelabGroup.cpp @@ -528,6 +528,10 @@ void onelabGroup::_addParameter(T &p) Fl_Color c; if(getFlColor(p.getAttribute("Highlight"), c)) highlight = true; Fl_Tree_Item *n = _tree->add(p.getName().c_str()); + if(!n){ + Msg::Debug("Could not add item '%s' in tree", p.getName().c_str()); + return; + } n->labelsize(FL_NORMAL_SIZE + 4); _tree->begin(); int ww = (int)(_baseWidth - (n->depth() + 1) * _indent); @@ -549,6 +553,10 @@ void onelabGroup::_addParameter(T &p) void onelabGroup::_addMenu(const std::string &path, Fl_Callback *callback, void *data) { Fl_Tree_Item *n = _tree->add(path.c_str()); + if(!n){ + Msg::Debug("Could not add item '%s' in tree", path.c_str()); + return; + } _tree->begin(); int ww = (int)(_baseWidth - (n->depth() + 1) * _indent); int hh = n->labelsize() + 4; @@ -575,6 +583,10 @@ void onelabGroup::_addSolverMenu(int num) std::ostringstream path; path << "0Modules/Solver/Solver" << num; Fl_Tree_Item *n = _tree->add(path.str().c_str()); + if(!n){ + Msg::Debug("Could not add item '%s' in tree", path.str().c_str()); + return; + } int ww = (int)(_baseWidth - (n->depth() + 1) * _indent); int hh = n->labelsize() + 4; _tree->begin(); @@ -592,6 +604,10 @@ void onelabGroup::_addViewMenu(int num) std::string path = getViewPathName(num); if(path.empty()) return; Fl_Tree_Item *n = _tree->add(path.c_str()); + if(!n){ + Msg::Debug("Could not add item '%s' in tree", path.c_str()); + return; + } int ww = (int)(_baseWidth - (n->depth() + 1) * _indent); int hh = n->labelsize() + 4; _tree->begin(); -- GitLab