×

Discussion Board

Page 1 of 3 123 LastLast
Results 1 to 15 of 32
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    12

    Crash in QWidget destruction - Help

    Hi,

    Please look at the following stack for a crash

    I am going back and forth between two screens and some times while deleting the screen (widget) end up with the crash in QWidget destructor while deleting extra data (Not sure what is that used for). Now the actual crash for some reason is in QString destructor though.

    Can it be due to something wrong with the stylesheet or .ui file?

    43 QBasicAtomicInt::deref() C:\Qt\4.6.2_Symbian\src\corelib\arch\qatomic_symbian.h:123 0x0274bf1d
    42 QString::~QString() C:\Qt\4.6.2_Symbian\src\corelib\tools\qstring.h:869 0x0274fc1b
    41 0x2F6AC6D( QtGui.dll )() 0x02f6ac6d
    40 0x2F6AC2C( QtGui.dll )() 0x02f6ac2c
    39 QWidgetPrivate::deleteExtra() C:\Qt\4.6.2_Symbian\src\gui\kernel\qwidget.cpp:1620 0x02f6abd1
    38 QWidgetPrivate::~QWidgetPrivate() C:\Qt\4.6.2_Symbian\src\gui\kernel\qwidget.cpp:231 0x02f68382
    37 0x2F80E1C( QtGui.dll )() 0x02f80e1c
    36 QScopedPointerDeleter<QObjectData>::cleanup() C:\Qt\4.6.2_Symbian\src\corelib\tools\qscopedpointer.h:63 0x028037f8
    35 QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData>>::~QScopedPointer() C:\Qt\4.6.2_Symbian\src\corelib\tools\qscopedpointer.h:100 0x028037c5
    34 QObject::~QObject() C:\Qt\4.6.2_Symbian\src\corelib\kernel\qobject.cpp:984 0x02803f11
    33 QWidget::~QWidget()

    Thanks
    AM

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Crash in QWidget destruction - Help

    Quote Originally Posted by amol.mahesh@gmail.com View Post
    Can it be due to something wrong with the stylesheet or .ui file?
    Providing stripped backtraces without sources is not useful.

  3. #3
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Crash in QWidget destruction - Help

    Not likely to be due to UI or stylesheet file. I managed to create something vaguely similar when I mixed metaphors and had a destructor method explicitly deleting objects that were (more or less simultaneously) being deleted by the parent-child mechanism.

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    12

    Re: Crash in QWidget destruction - Help

    Thanks.
    All I am deleting in my destructor is the "ui" pointer which was created in constructor.
    Now again this code was created by the QT Creator as a default template. But I am not deleting any other child
    AM

  5. #5
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Crash in QWidget destruction - Help

    Are you by any chance using any QScopedPointers?

  6. #6
    Registered User
    Join Date
    Jan 2010
    Posts
    12

    Re: Crash in QWidget destruction - Help

    Not directly in my code. Looks like QWidget, QObject uses it though.
    AM

  7. #7
    Registered User
    Join Date
    Jan 2010
    Posts
    12

    Re: Crash in QWidget destruction - Help

    Is it required that i should disconnect all signals and slots in my destructor?
    AM

  8. #8
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Crash in QWidget destruction - Help

    No. It's unlikely that signal/slot connections would have anything to do with this. Most likely you're violating one of the written or unwritten rules of Qt heap management, but these problems can be very difficult to sort out.

    Quote Originally Posted by amol.mahesh@gmail.com View Post
    Is it required that i should disconnect all signals and slots in my destructor?

  9. #9
    Registered User
    Join Date
    Jan 2010
    Posts
    12

    Re: Crash in QWidget destruction - Help

    More Info.

    inline QString::~QString() { if (!d->ref.deref()) free(d); }

    d is coming as 0 in this case.

    Infact this "delete extra" which is causing this crash is not understood as well. If i look at the extra structure variables after crash, I do not see any thing that needs to be deleted as every thing is already deleted.
    AM

  10. #10
    Registered User
    Join Date
    Jul 2010
    Posts
    9

    Re: Crash in QWidget destruction - Help

    Were you able to sort this out? You are describing pretty much the same problem I am having at the moment (on Linux / i386)

  11. #11
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Crash in QWidget destruction - Help

    My guess is that you're deleting something that "belongs" to QObject in your destructor.

  12. #12
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Crash in QWidget destruction - Help

    Use CONFIG += debug option to have debug symbols in binary and then use
    gdb -c path_to_coredump path_to_your_binary
    and then bt to get a backtrace.

  13. #13
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Crash in QWidget destruction - Help

    Looking at the code in detail, I'm wondering if you've maybe stomped on your object. QScopedPointer destructor should be deleting a QThreadData object, not a widget.

  14. #14
    Registered User
    Join Date
    Jul 2010
    Posts
    9

    Re: Crash in QWidget destruction - Help

    I figured out what the problem was in my case: Just the kind of classic C++ coding mistake you make when you spoiled yourself with Java or C# too much. The crash occurred when I called a method that was supposed to return a QString, but missed the actual return statement. In Java or C# that code wouldn't even compile, while good old g++ doesn't even bother to give you a warning ... hope this helps.

  15. #15
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Crash in QWidget destruction - Help

    Quote Originally Posted by hagbard5 View Post
    In Java or C# that code wouldn't even compile, while good old g++ doesn't even bother to give you a warning ... hope this helps.
    I'm using g++ and have a warning
    Code:
    #include <QtCore>
    
    QString returnString()
    {
        QString str = "string";
    }
    
    
    int main (int argc, char **argv)
    {
        QCoreApplication app(argc, argv);
    
        qDebug() << returnString();
    }
    Code:
    g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o main.o main.cpp
    main.cpp: In function ‘QString returnString()’:
    main.cpp:6: warning: no return statement in function returning non-void
    g++ -Wl,-O1 -o geo main.o    -L/usr/lib -lQtGui -lQtCore -lpthread

Similar Threads

  1. Replies: 0
    Last Post: 2010-03-12, 20:11
  2. How to use carbide Crash Debugger
    By a14776584 in forum Symbian
    Replies: 3
    Last Post: 2010-01-11, 19:46
  3. How to use carbide Crash Debugger
    By a14776584 in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2010-01-11, 05:54
  4. How to use crash monitor
    By islamfunny in forum Symbian
    Replies: 3
    Last Post: 2009-06-28, 15:31

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×