diff --git a/src/Fl_Tree.cxx b/src/Fl_Tree.cxx index 139e8ed6d..244d7b0f4 100644 --- a/src/Fl_Tree.cxx +++ b/src/Fl_Tree.cxx @@ -1135,6 +1135,7 @@ void Fl_Tree::clear() { if ( ! _root ) return; _root->clear_children(); delete _root; _root = 0; + _item_focus = 0; } /// Clear all the children for \p 'item'. diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx index 7cd66b061..b046f65fd 100644 --- a/src/Fl_Tree_Item.cxx +++ b/src/Fl_Tree_Item.cxx @@ -116,6 +116,11 @@ Fl_Tree_Item::~Fl_Tree_Item() { _usericon = 0; // user handled allocation #if FLTK_ABI_VERSION >= 10304 if ( _userdeicon ) delete _userdeicon; // delete our copy (if any) for deactivated icon +#endif +#if FLTK_ABI_VERSION >= 10303 + // focus item? set to null + if ( _tree && this == _tree->_item_focus ) + { _tree->_item_focus = 0; } #endif //_children.clear(); // array's destructor handles itself }