Results 1 to 11 of 11

Thread: QDockWidget: Debugging crash

  1. #1
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QDockWidget: Debugging crash

    Hi

    I am porting Kalzium from Qt3 to Qt4. The last Qt3-class which needed porting is the toolbox, which is in a QDockWindow (Qt3) and now in a QDockWidget (Qt 4.1).

    This is a screenshot of the Qt3.5-version. I am talking about the widget on the left.



    Everything looks fine so far, but when I click on the little area on top of the window (directly over the word "Overview") it crashes. You can read the sourcecode here: http://websvn.kde.org/trunk/KDE/kdee...94861&view=log

    The QDockWidget is created here:

    Qt Code:
    1. m_toolbox = new QToolBox( this );
    2. m_dockWin = new QDockWidget("test");
    3.  
    4. m_dockWin->setWidget( m_toolbox );
    5. m_dockWin->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
    To copy to clipboard, switch view to plain text mode 

    this is the KMainWindow. The widgets in the QToolBox work as expected, the crash only happens if you click on the small area.

    Ideas?

  2. #2
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: QDockWidget: Debugging crash

    Isn't a dockwidget without parent bad? I can imagine that the dockwidget tries to communicate with the mainWindow when you click on the header for dock/undock purposes.

    Edit:

    At least, you miss some addDockWidget() calls.
    Last edited by axeljaeger; 7th January 2006 at 11:01.
    It's nice to be important but it's more important to be nice.

  3. #3
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QDockWidget: Debugging crash

    Between line 1 ans 2 insert:
    Qt Code:
    1. Q_CHECK_PTR(m_toolBox);
    To copy to clipboard, switch view to plain text mode 
    In line 3 insert:
    Qt Code:
    1. Q_CHECK_PTR(m_dockWin);
    To copy to clipboard, switch view to plain text mode 
    so we can see if pointer are ok. If that is ok, than we'll move forward.
    Qt 5.3 Opensource & Creator 3.1.2

  4. #4
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default The debug output

    #0 0xb6a51dea in QWidget::d_func (this=0x0) at qwidget.h:115
    #1 0xb6a4571d in QWidget::layout (this=0x0) at kernel/qwidget.cpp:6075
    #2 0xb6c6cf1c in QDockWidgetPrivate::mousePressEvent (this=0x81377f0, event=0xbfe6c184) at widgets/qdockwidget.cpp:345
    #3 0xb6c6dadf in QDockWidget::event (this=0x81361e0, event=0xbfe6c184) at widgets/qdockwidget.cpp:815
    #4 0xb6a058ad in QApplicationPrivate::notify_helper (this=0x80aaa28, receiver=0x81361e0, e=0xbfe6c184) at kernel/qapplication.cpp:3116
    #5 0xb6a06348 in QApplication::notify (this=0xbfe6c754, receiver=0x81361e0, e=0xbfe6c184) at kernel/qapplication.cpp:2849
    #6 0xb71f7b36 in KApplication::notify (this=0xbfe6c754, receiver=0x81361e0, event=0xbfe6c184) at /home/kde4/svn/kdelibs4_snapshot/kdecore/kapplication.cpp:404
    #7 0xb6a0d5e7 in QCoreApplication::sendSpontaneousEvent (receiver=0x81361e0, event=0xbfe6c184) at qcoreapplication.h:174
    #8 0xb6a64d2c in QETWidget::translateMouseEvent (this=0x81361e0, event=0xbfe6c5e0) at kernel/qapplication_x11.cpp:3576
    #9 0xb6a62d14 in QApplication::x11ProcessEvent (this=0xbfe6c754, event=0xbfe6c5e0) at kernel/qapplication_x11.cpp:2701
    #10 0xb6a7473f in QEventDispatcherX11:rocessEvents (this=0x80af2c8, flags=@0xbfe6c694) at kernel/qeventdispatcher_x11.cpp:112
    #11 0xb66bdf56 in QEventLoop:rocessEvents (this=0xbfe6c70c, flags=@0xbfe6c6cc) at kernel/qeventloop.cpp:118
    #12 0xb66be1e1 in QEventLoop::exec (this=0xbfe6c70c, flags=@0xbfe6c714) at kernel/qeventloop.cpp:158
    #13 0xb66c33ea in QCoreApplication::exec () at kernel/qcoreapplication.cpp:661
    #14 0xb6a05045 in QApplication::exec () at kernel/qapplication.cpp:2664
    #15 0x08066415 in main (argc=1, argv=0xbfe6c824) at /home/kde4/svn/kdeedu/kalzium/src/main.cpp:93

  5. #5
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QDockWidget: Debugging crash

    Did you insert Q_CHECK_PTR as I said?
    Qt 5.3 Opensource & Creator 3.1.2

  6. #6
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: QDockWidget: Debugging crash

    I still think that the parent() of the QDockWidget is 0.
    It's nice to be important but it's more important to be nice.

  7. #7
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QDockWidget: Debugging crash

    So, the code:
    Qt Code:
    1. m_dockWin = new QDockWidget("test");
    To copy to clipboard, switch view to plain text mode 
    should be:
    Qt Code:
    1. m_dockWin=new QDockWidget(QString("test"), this);
    To copy to clipboard, switch view to plain text mode 
    Last edited by MarkoSan; 7th January 2006 at 11:37.
    Qt 5.3 Opensource & Creator 3.1.2

  8. #8
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: QDockWidget: Debugging crash

    Either this or the dock widgets should be added later using addDockWidget. I think this sets the parent too.
    It's nice to be important but it's more important to be nice.

  9. #9
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDockWidget: Debugging crash

    This is the current code, still crashing. As soon as I make the m_dockWin a child of "this" it is *in* the mainwindow. So that cannot be right.

    Qt Code:
    1. m_dockWin = new QDockWidget("test");
    2. Q_CHECK_PTR( m_dockWin );
    3.  
    4. m_toolbox = new QToolBox( this );
    5. Q_CHECK_PTR( m_toolbox );
    6.  
    7. m_dockWin->setWidget( m_toolbox );
    8. m_dockWin->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
    To copy to clipboard, switch view to plain text mode 

    I noticed this in the shell when executing Kalzium
    QLayout::addChildWidget: QToolBox "" in wrong parent; moved to correct parent
    class Kalzium is:

    Qt Code:
    1. Kalzium::Kalzium()
    2. : KMainWindow( 0, "Kalzium" )
    3. {
    To copy to clipboard, switch view to plain text mode 

    I don't know the check-pointer-macro, but I don't see any information in the shell. Is this supposed to help in gdb?

  10. #10
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QDockWidget: Debugging crash

    Like axeljaeger said, you should also use addDockWidget().
    Qt 5.3 Opensource & Creator 3.1.2

  11. #11
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDockWidget: Debugging crash

    Ok, I just debugged a little more. The problem seems to be that KMainWindow does *not* inherit from QMainWindow but from Q3MainWindow. And Q3MainWindow doesn't know anything about QDockWidget but only about QDockWindow. Therefore, somewhere in the Q3Compatlib it crashes.
    So somebody needs to port KMainWindow of KDE4 first.

Similar Threads

  1. QDockWidget magically disapear
    By 1111 in forum Qt Programming
    Replies: 1
    Last Post: 29th January 2009, 12:44
  2. Program crashes with assert error in xcb_lock.c
    By Valheru in forum Qt Programming
    Replies: 3
    Last Post: 18th November 2007, 20:56
  3. KDE 3.5.0 crash while opening project
    By MarkoSan in forum KDE Forum
    Replies: 2
    Last Post: 19th October 2007, 17:21

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.