Addresses issue raised by Michael Sartain on fltk.coredev on 02/11/2016;

prevent problems with Fl_Tree::_item_focus remaining valid after clear().
Applied his patch, plus extra checks added to Fl_Tree_Item's dtor.



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@11173 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Greg Ercolano 2016-02-14 14:29:47 +00:00
parent 0462cae6d1
commit f6e6c20843
2 changed files with 6 additions and 0 deletions

View File

@ -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'.

View File

@ -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
}