[Qt-interest] QStackedWidget crash, but only when running in debugger

Andre Somers andre at familiesomers.nl
Wed Nov 4 15:54:46 CET 2009


Hi Ian (and others),

Thanks for your reply.
I understand that a small compilable example is best, but it is not easy 
to extract one that has the same bug in my code that I'm trying to find 
& fix.
Yes, I am pretty sure the bug is my code, at least untill I find solid 
evidence that it is not. I assume Qt is not broken at the moment, and I 
have used stacked widgets before without any problem.

The question isn't so much for concrete pointers to what I could be 
doing wrong (but thanks, I checked your suggestion and I am calling 
setupUi where needed), but for how I can debug this issue. I am trying 
to come to terms to the debugger indicating a crash at a point where I 
really can not find anything that looks wrong in the stack trace. It is 
a lack of debugging skills on my side I'm sure... Issues like 
dereferencing 0 pointers and the likes I am able to spot just fine, but 
this looks perfectly OK to my eyes...

André


Ian Thomson wrote:
> Hi Andre,
>
> This shouldn't happen. However, you haven't provided enough information 
> for anyone to know why it happens. A small compilable example is always 
> best.
>
> Just because it crashes in the debugger doesn't mean the debugger is the 
> problem. Not all bad things cause crashes all the time, your 
> non-debugged program could still be referencing invalid memory but due 
> to the way the program is run, it gets lucky and doesn't crash.
>
> Random guess: Did you forget to call setupUi on your designer created form?
>
> Cheers,
> Ian Thomson
>
> Andre Somers wrote:
>   
>> Nobody?
>>
>> Andre Somers wrote:
>>     
>>> Hi,
>>>
>>> I am running into an annoying problem using the debugger from Qt Creator 
>>> (from 2009.3 SDK for Windows XP). I am trying to debug a crash in my 
>>> application. The problem is, the application crashes at startup in the 
>>> debugger, while in the normal situation it runs perfectly fine using 
>>> exactly the same build (debug). The crash occurs at a moment a widget is 
>>> added to a QStackedWidget using addWidget(configuration).
>>>
>>> QWidget* configuration = ext->configurationWidget(0);
>>>
>>> if (configuration) {
>>>
>>> ui.propertyStack->addWidget(configuration);
>>>
>>> connect(ext, SIGNAL(closeConfiguration()), this, 
>>> SLOT(closePropertyConfiguration()));
>>>
>>> }
>>>
>>>
>>> The call is made at the third line of the code above. At the moment of 
>>> calling, both the QStackedWidget ui.propertyStack and the configuration 
>>> widget I am trying to add are perfectly valid pointers.
>>>
>>> This is the stacktrace I get. The call is made from the function at 
>>> level 6.
>>>
>>> 0    QObject::parent    qobject.h    243   
>>> 1    QWidget::parentWidget    qwidget.h    988   
>>> 2    QLayout::addChildWidget    qlayout.cpp    948   
>>> 3    QStackedLayout::insertWidget    qstackedlayout.cpp    213   
>>> 4    QStackedLayout::addWidget    qstackedlayout.cpp    193   
>>> 5    QStackedWidget::addWidget    qstackedwidget.cpp    166   
>>> 6    MatrixSetup::addPropertyExtension    matrixsetup.cpp    651   
>>> 7    MatrixSetup::initializePropertyExtensionTree    matrixsetup.cpp    
>>> 637   
>>> 8    MatrixSetup::MatrixSetup    matrixsetup.cpp    105   
>>> 9    Ui_MainUi::setupUi    ui_main.h    140   
>>> 10    MainUiMatrixCompiler::MainUiMatrixCompiler    mainui.cpp    15   
>>> 11    qMain    main.cpp    16   
>>> 12    WinMain    qtmain_win.cpp    136   
>>> 13    main        0   
>>>
>>> Can anyone please point me to an explanation on what's going on here, 
>>> and to get around it? It is very annoying that the debugger seems to 
>>> trigger bugs all by itself... That makes debugging *actual* problems 
>>> quite a bit harder and more time consuming than nessecairy.
>>>
>>> Thanks,
>>>
>>> André
>>>       
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>   




More information about the Qt-interest-old mailing list