MainWindow destructor
-
Hi,
I have the following destructor
@MainWindow::~MainWindow()
{
disconnect(plugNPlay, SIGNAL(hid_comm_update(bool, int)), this, SLOT(update_gui(bool, int)));
delete plugNPlay;
delete ui;
delete m_undoStack;
}@where in the constructor, I have the following
@plugNPlay = new HID_PnP();
m_undoStack = new QUndoStack(this);@Now I get an error when exiting the destructor above "...write access error at 0x8..."
Any idea?
HID_PnP() is running a thread where its personnal destructor is@HID_PnP::~HID_PnP() {
closeDevice();
disconnect(timer, SIGNAL(timeout()), this, SLOT(PollUSB()));
this->quit();
this->wait();
delete timer;
}@ -
I'm not sure you should directly delete m_undoStack. It's because you set parent for it, so its parent is going to delete it itself. And any other qt-objects with qt-parent set too.
-
yes you are right... but even if I remove it, I still get the same error.
-
You can continue debugging at the end of the destructor; you will end up in the destructors of the MainWindow member variables and maybe see the exact position of the crash.
-
I get the error when I reach the end of MainWindow... so its difficult to see what is next.
If I look at the Windows task manager of the release version, the .exe will stay for ~5 seconds then disapear.
-
Set in debugger to catch errors/exceptions in the place of throw. This way you will get callstack of modules and the topmost is the place of throw. If you don't see module details then make sure you have symbols/pdb. Have you tried 'debug' version? it could give you more clues about the problems in your program.
-
ok... will try that