From e511e2ba1150ea6d29247a0912ae5efca22415e8 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Tue, 5 Apr 2011 12:44:16 +0000 Subject: [PATCH] Romulo: -Solved bug 295 + SelectedItemChangedInTree() event was called after the window had been closed and the object instance had been destroyed. + Horrible solution: added a static "destroyed" flag to indicate that the object instance has been destroyed. * Flag will be valid for all active instances, since it's static. + In desperate need of a better solution! * Need to find the correct location to put it, though. --- vv/vvToolStructureSetManager.cxx | 22 ++++++++++++++++++++++ vv/vvToolStructureSetManager.h | 1 + 2 files changed, 23 insertions(+) diff --git a/vv/vvToolStructureSetManager.cxx b/vv/vvToolStructureSetManager.cxx index 6440a75..c9e3368 100644 --- a/vv/vvToolStructureSetManager.cxx +++ b/vv/vvToolStructureSetManager.cxx @@ -41,6 +41,7 @@ ADD_TOOL(vvToolStructureSetManager); int vvToolStructureSetManager::m_NumberOfTool = 0; std::vector vvToolStructureSetManager::mListOfInputs; std::map vvToolStructureSetManager::mListOfOpenTool; +bool vvToolStructureSetManager::mDestroyed = false; //------------------------------------------------------------------------------ vvToolStructureSetManager::vvToolStructureSetManager(vvMainWindowBase * parent, @@ -99,7 +100,9 @@ vvToolStructureSetManager::vvToolStructureSetManager(vvMainWindowBase * parent, //------------------------------------------------------------------------------ vvToolStructureSetManager::~vvToolStructureSetManager() { + //std::cout << "vvToolStructureSetManager::~vvToolStructureSetManager()" << std::endl; m_NumberOfTool--; + mDestroyed=true; } //------------------------------------------------------------------------------ @@ -119,6 +122,8 @@ void vvToolStructureSetManager::Initialize() { //------------------------------------------------------------------------------ void vvToolStructureSetManager::InputIsSelected(vvSlicerManager *m) { + //std::cout << "vvToolStructureSetManager::InputIsSelected()" << std::endl; + //int mTabNumber = parent->GetTab()->addTab(this, ""); // this->setFixedWidth(120); //this->setPreferedHeight(441); @@ -356,6 +361,7 @@ void vvToolStructureSetManager::apply() //------------------------------------------------------------------------------ bool vvToolStructureSetManager::close() { + //std::cout << "vvToolStructureSetManager::close()" << std::endl; return vvToolWidgetBase::close(); } //------------------------------------------------------------------------------ @@ -364,6 +370,9 @@ bool vvToolStructureSetManager::close() //------------------------------------------------------------------------------ void vvToolStructureSetManager::closeEvent(QCloseEvent *event) { + //std::cout << "vvToolStructureSetManager::closeEvent()" << std::endl; + disconnect(mTree, SIGNAL(itemSelectionChanged())); + std::vector::iterator iter = std::find(mListOfInputs.begin(), mListOfInputs.end(), mCurrentSlicerManager); if (iter != mListOfInputs.end()) mListOfInputs.erase(iter); @@ -393,6 +402,17 @@ void vvToolStructureSetManager::closeEvent(QCloseEvent *event) //------------------------------------------------------------------------------ void vvToolStructureSetManager::SelectedItemChangedInTree() { + + // ATTENTION: + // RP - 05/04/2011 + // Horrible solution for the problem of triggering this event + // after the window has been closed and the object instance + // has been destroyed. I couldn't find the place where the + // window is destroyed, though. + // + if (mDestroyed) + return; + // Search which roi is selected QList l = mTree->selectedItems(); if (l.size() == 0) { @@ -402,6 +422,8 @@ void vvToolStructureSetManager::SelectedItemChangedInTree() { return; } QTreeWidgetItem * w = l[0]; + //std::cout << "selected item -> " << w->text(1).toStdString() << std::endl; + //std::cout << "m_NumberOfTool -> " << m_NumberOfTool << std::endl; if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) { mCurrentROIActor = NULL; mCurrentROI = NULL; diff --git a/vv/vvToolStructureSetManager.h b/vv/vvToolStructureSetManager.h index e768691..376b20a 100644 --- a/vv/vvToolStructureSetManager.h +++ b/vv/vvToolStructureSetManager.h @@ -93,6 +93,7 @@ protected: virtual void CheckInputList(std::vector & l, int & index); static std::vector mListOfInputs; static std::map mListOfOpenTool; + static bool mDestroyed; static int m_NumberOfTool; bool MustOpenDialogWhenCreated; -- 2.47.1