Hi Sebastian,

I have created a bug for this issue: http://bugs.mitk.org/show_bug.cgi?id=7772. 
I`ll let you know when I tested this.

Thanks for the contribution
Michael

-----Ursprüngliche Nachricht-----
Von: sebastian ordas [mailto:[email protected]] 
Gesendet: Dienstag, 12. April 2011 15:06
An: [email protected]
Betreff: [mitk-users] a better way to remove nodes in data manager

Dear All,

Find below, in my opinion, a better way of removing nodes in Data Manager.
The current approach does not really release memory (see e.g. the memory 
indicator)

Please try it out and let me know if I was right or wrong

thank you!
sebastian

void QmitkDataManagerView::RemoveSelectedNodes( bool )
{
   QModelIndexList indexesOfSelectedRows = 
m_NodeTreeView->selectionModel()->selectedRows();
   if(indexesOfSelectedRows.size() < 1)
   {
     return;
   }

   std::vector<mitk::DataNode*> selectedNodes;

   QString question = tr("Do you really want to remove ");

   for (QModelIndexList::iterator it = indexesOfSelectedRows.begin()
     ; it != indexesOfSelectedRows.end(); it++)
   {
     mitk::DataNode* node = 0;
     node = m_NodeTreeModel->GetNode(*it);
     // if node is not defined or if the node contains geometry data do 
not remove it
     if ( node != 0 /*& strcmp(node->GetData()->GetNameOfClass(), 
"Geometry2DData") != 0*/ )
     {
       selectedNodes.push_back(node);
       question.append(QString::fromStdString(node->GetName()));
       question.append(", ");
     }
   }
   // remove the last two characters = ", "
   question = question.remove(question.size()-2, 2);
   question.append(" from data storage?");

   QMessageBox::StandardButton answerButton = QMessageBox::question( 
m_Parent
     , tr("DataManager")
     , question
     , QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);

   if(answerButton == QMessageBox::Yes)
   {
     for (std::vector<mitk::DataNode*>::iterator it = selectedNodes.begin()
       ; it != selectedNodes.end(); it++)
     {
       mitk::DataNode::Pointer node = *it;
       this->GetDataStorage()->Remove(node);
       node->SetData(NULL);
     }
     this->GlobalReinit(false);
   }
}

------------------------------------------------------------------------------
Forrester Wave Report - Recovery time is now measured in hours and minutes
not days. Key insights are discussed in the 2010 Forrester Wave Report as
part of an in-depth evaluation of disaster recovery service providers.
Forrester found the best-in-class provider in terms of services and vision.
Read this report now!  http://p.sf.net/sfu/ibm-webcastpromo
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

------------------------------------------------------------------------------
Forrester Wave Report - Recovery time is now measured in hours and minutes
not days. Key insights are discussed in the 2010 Forrester Wave Report as
part of an in-depth evaluation of disaster recovery service providers.
Forrester found the best-in-class provider in terms of services and vision.
Read this report now!  http://p.sf.net/sfu/ibm-webcastpromo
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to