Results 1 to 5 of 5

Thread: Problem with delating main widget components (backtrace included)

  1. #1
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problem with delating main widget components (backtrace included)

    I've an application (~1500 lines of code) that crashes after trying to destroy my main widget(class's name is LibWin and is derivated directly from QWidget). Often when I order program to quit using qApp->quit() the window doesn't dissapear but it stays and doesn't respond to any clicking.

    Here's backtrace from debugger:
    #0 0xb7240a2f in free () from /lib/tls/i686/cmov/libc.so.6
    #1 0xb73effc1 in operator delete () from /usr/lib/libstdc++.so.6
    #2 0xb7be5119 in ~QComboBox (this=0x811c2b4) at widgets/qcombobox.cpp:1058
    #3 0xb75cdea1 in QObjectPrivate::deleteChildren (this=0x812bdc8) at kernel/qobject.cpp:1823
    #4 0xb7981649 in ~QWidget (this=0x811c3d4) at kernel/qwidget.cpp:1158
    #5 0xb7c10791 in ~QGroupBox (this=0x811c3d4) at widgets/qgroupbox.cpp:189
    #6 0x0805c426 in LibWin::~LibWin ()
    #7 0x0805bfbe in main ()

    could you suggest me a few possible reasons (maybe it is commonplace for newbie's to have their widgets undelated).

    I may attach a whole project but it is quite heavy and I don't know whether any of you have enough time to scan the code.

    Mike

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Problem with delating main widget components (backtrace included)

    Perhaps you try to delete something which has already been deleted? You know, a QObject automatically deletes it's children. Also, you should not accidentally delete any objects allocated on the stack (the main window?).
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with delating main widget components (backtrace included)

    Most often you can create the main window object on the stack in your main() method so that it is destroyed automatically when it goes out of scope (when main() returns). This way you don't have to care about deleting it.

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with delating main widget components (backtrace included)

    I may attach a whole project but it is quite heavy and I don't know whether any of you have enough time to scan the code.
    Attach only the destructor of LibWin.

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with delating main widget components (backtrace included)

    Quote Originally Posted by wysota View Post
    Most often you can create the main window object on the stack in your main() method so that it is destroyed automatically when it goes out of scope (when main() returns). This way you don't have to care about deleting it.
    But this is what he did. Just look at the trace.
    Delete would have been in the trace if he had called "delete libwin;".

    Anyway, most likely jpn is right - that QComboBox has been deleted somewhere else.

    Regards

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.