[Qt-creator] Help debugging a heap error

Murphy, Sean smurphy at walbro.com
Thu Jun 5 16:00:08 CEST 2014


> Double deletion of a QAction(-derived) object.
> How are your QActions created (Stack/Heap)? Do you use any other life-time management (Smart pointers?) besides assigning a QObject parent?

I did a search of QAction in the current project and all of my QAction objects are declared like so:
   QAction* myAction = new QAction("blag", this);
I'm not using any smart pointers, and I don't have any QAction objects on the stack.

I did get rid of the segfault by removing:
  serPort->deleteLater();
from my MainWindow destructor.  "serPort" is a QSerialPort object that I created in the MainWindow constructor with no parent, then created a QThread object (which also apparently had no parent? This seems wrong?), and then moved the serial port object to that thread.  I think maybe I need to parent the QThread object, but I don't know if this is what was causing the problem or not.  The code, as I originally had it (with the deleteLater() call) had been working for months, so I'm not sure what I did to change this.  As far as I know, I've only recently been making GUI changes, that shouldn't have anything to do with the thread.

But I think my real question right now is, how can I use QtCreator's debugging setup to help track this down?  Currently I'm setting a breakpoint at MainWindow::~MainWindow, then I step through my MainWindow destructor, all of my code works, it's only as I exit my destructor and all the Qt child deletion stuff happens that it segfaults.  I'm building my stuff in debug mode, and Dependency Walker claims the debug executable is looking for all the Qt debug libraries (Qt*d.dll), but I don't seem to be able to step into Qt code to know which QAction is causing the problem.

Sean



More information about the Qt-creator mailing list