#include <QFileDialog>
#include <QMessageBox>
#include <QColorDialog>
-
+#include <QAbstractEventDispatcher>
+
// vtk
#include <vtkLookupTable.h>
#include <vtkRenderWindow.h>
int vvToolStructureSetManager::m_NumberOfTool = 0;
std::vector<vvSlicerManager*> vvToolStructureSetManager::mListOfInputs;
std::map<vvSlicerManager*, vvToolStructureSetManager*> vvToolStructureSetManager::mListOfOpenTool;
-bool vvToolStructureSetManager::mDestroyed = false;
//------------------------------------------------------------------------------
vvToolStructureSetManager::vvToolStructureSetManager(vvMainWindowBase * parent,
//------------------------------------------------------------------------------
vvToolStructureSetManager::~vvToolStructureSetManager()
{
- //std::cout << "vvToolStructureSetManager::~vvToolStructureSetManager()" << std::endl;
m_NumberOfTool--;
- mDestroyed=true;
+
+ // clearing the list at this point avoids
+ // segfaulting due to events being dispatched
+ // after object destruction
+ mTreeWidgetList.clear();
+ mTree->clearSelection();
+
+ //std::cout << "vvToolStructureSetManager::~vvToolStructureSetManager()" << std::endl;
}
//------------------------------------------------------------------------------
bool vvToolStructureSetManager::close()
{
//std::cout << "vvToolStructureSetManager::close()" << std::endl;
+
return vvToolWidgetBase::close();
}
//------------------------------------------------------------------------------
void vvToolStructureSetManager::closeEvent(QCloseEvent *event)
{
//std::cout << "vvToolStructureSetManager::closeEvent()" << std::endl;
- disconnect(mTree, SIGNAL(itemSelectionChanged()));
std::vector<vvSlicerManager*>::iterator iter = std::find(mListOfInputs.begin(), mListOfInputs.end(), mCurrentSlicerManager);
if (iter != mListOfInputs.end()) mListOfInputs.erase(iter);
//------------------------------------------------------------------------------
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<QTreeWidgetItem *> l = mTree->selectedItems();
if (l.size() == 0) {
Q_OBJECT
public:
vvToolStructureSetManager(vvMainWindowBase* parent=0, Qt::WindowFlags f=0, vvSlicerManager * c = NULL);
- ~vvToolStructureSetManager();
+ virtual ~vvToolStructureSetManager();
static void Initialize();
virtual void InputIsSelected(vvSlicerManager *m);
virtual void CheckInputList(std::vector<vvSlicerManager*> & l, int & index);
static std::vector<vvSlicerManager*> mListOfInputs;
static std::map<vvSlicerManager*, vvToolStructureSetManager*> mListOfOpenTool;
- static bool mDestroyed;
static int m_NumberOfTool;
bool MustOpenDialogWhenCreated;