From 282389f0b14ca4f8ce01fad3f1f6eec6ce2fb760 Mon Sep 17 00:00:00 2001 From: san Date: Wed, 28 Mar 2012 17:38:09 +0000 Subject: [PATCH] Clear all TreeItem instances in SUIT_TreeModel::setRoot() when autoDeleteTree == true to avoid crashes on model reset resulted from incorrect value returned by rowCount() --- src/SUIT/SUIT_TreeModel.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SUIT/SUIT_TreeModel.cxx b/src/SUIT/SUIT_TreeModel.cxx index a6ff0c455..8893581a2 100755 --- a/src/SUIT/SUIT_TreeModel.cxx +++ b/src/SUIT/SUIT_TreeModel.cxx @@ -775,6 +775,12 @@ void SUIT_TreeModel::setRoot( SUIT_DataObject* r ) SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ), this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) ); delete myRoot; + + if ( myRootItem ) { + QList items = myRootItem->children(); + for ( QList::iterator anIt = items.begin(); anIt != items.end(); anIt++ ) + delete *anIt; + } } myRoot = r; -- 2.39.2