[Qt-interest] Re : crash in destructor of mainwindow?

BOUCARD Olivier boucard_olivier at yahoo.fr
Mon Jul 12 11:38:54 CEST 2010


I remember I've got this kind of error. I don't know if its the same case for 
you.
But, this can happen when children are not declared in the heap but on the 
stack.
If the parent is destroyed after the children get out of their scope, it tries 
to delete already deleted object.
In addition, call a delete on an address from the stack, its not a good idea.




________________________________
De : Matthias Pospiech <matthias.pospiech at gmx.de>
À : "qt-interest at trolltech.com" <qt-interest at trolltech.com>
Envoyé le : Lun 12 juillet 2010, 11h 26min 35s
Objet : [Qt-interest] crash in destructor of mainwindow?

I get this crash, which I do not understand:

Stack Trace:

0    QObjectPrivate::deleteChildren    qobject.cpp    1978    0x6a20f02b  
1    ~QWidget    qwidget.cpp    1469    0x006ac6f3  
2    ~QDialog    qdialog.cpp    328    0x00aeaeb4  
3    ~DialogCameraSMX    DialogCameraSMX.cpp    24    0x00401c9c  
4    QObjectPrivate::deleteChildren    qobject.cpp    1978    0x6a20f038  
5    ~QWidget    qwidget.cpp    1469    0x006ac6f3  
6    ~QMainWindow    qmainwindow.cpp    341    0x00a4149c  
7    ~MainWindow    mainwindow.cpp    22    0x0040175f  
8    main    main.cpp    9    0x00401419  


crash in last line of:

void QObjectPrivate::deleteChildren()
{
    const bool reallyWasDeleted = wasDeleted;
    wasDeleted = true;
    // delete children objects
    // don't use qDeleteAll as the destructor of the child might
    // delete siblings
    for (int i = 0; i < children.count(); ++i) {
        currentChildBeingDeleted = children.at(i);
        children[i] = 0;
        delete currentChildBeingDeleted;


Why does this happen?

Matthias
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100712/c365e542/attachment.html 


More information about the Qt-interest-old mailing list