Debug work not release !



  • Ok every thing is in the title !
    In debug mode my prog is working fine
    In release mode my program launch and quit instantanously with the error code -1073741511

    I just want to say WT* ?

    From where this could be comming there is no warning or error to the compilation and the qmake is made well every thing should be fine and it's not !

    Someone have an idea ?

    EDIT:
    it seems it's comming from this simple line :
    QTabWidget* onglets = new QTabWidget(&fenetre);
    when i put it in com (and every thing related) the program is working fine (well there is nothing in !)
    When i just get it off from com the program crashes !
    Someone know from where its comming ?



  • Uh oh. There might be a memory corruption happening anywhere else in the program that causes the crash at some point. This can be extremely hard to track down because as you see, the crashes seem to be related to very strange conditions, although those conditions only change the memory layout in a way that then makes the corruption surface via crash.

    But let's hope this isn't the case. What is the window "fenetre"? Is it on the stack (i.e. why isn't it a pointer already)?

    Try to post all the other code that you commented out, i.e. all that's related to the tab widget.



  • i would agree but in fact there is only this line which is causing the problem
    here is my main :

    QApplication app(argc, argv);
    
    QWidget fenetre;
    
    QTabWidget* onglets = new QTabWidget(&fenetre);
    
    fenetre.show();
    
    return app.exec();
    

    this way it doesn't work but this way it works :

    QApplication app(argc, argv);
    
    QWidget fenetre;
    
    //QTabWidget* onglets = new QTabWidget(&fenetre);
    
    fenetre.show();
    
    return app.exec();
    

    but it's not really usefull ! the usefull one is this one :

    QApplication app(argc, argv);
    
    QWidget fenetre;
    
    QTabWidget onglets(&fenetre);
    
    fenetre.show();
    
    return app.exec();
    

    there were the three tests !

    (in fact now i use the third because it works and it's not very important to me to have a pointer in this little portion of code but i would like to know why is there an error only when i release ?)



  • I've tried @ QApplication app(argc, argv);
    QWidget fenetre;
    QTabWidget* onglets = new QTabWidget(&fenetre);
    fenetre.show();
    return app.exec();@
    Under Qt 4.8.1, 4.8.0 and 4.7.4 both debug and release, and it never crashes. So the error is probably in some other code. And quite frankly I don't see what should go wrong with the code you show. Normally it's not wise to pass stack pointers to heap allocated objects, but in this case It should be okay because it's the stack frame of main() which only gets unrolled on program termination. And since you're giving the pointer as QObject parent, this unrolling of fenetre should gracefully delete onglets, too.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.