Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QDockWidget with QML crash



  • Hi. I have simple app from this forum with QDockWidget and qml. Every time i try to undock the QDockWidget, the application crash.

    Environment: Ubuntu 18.04, Qt Creator 4.7.2, Qt 5.10.1

    The code below:

    main.cpp:

    int main(int argc, char *argv[])
    {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        QApplication app(argc, argv);
    
        QMainWindow mainWindow;
        {
            auto centalWidget = new QWidget(&mainWindow);
            mainWindow.setCentralWidget(centalWidget);
        }
    
        {
            auto dockWidget = new QDockWidget("One", &mainWindow);
            dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
            auto view = new QQuickWidget(dockWidget);
            view->setResizeMode(QQuickWidget::SizeRootObjectToView);
            dockWidget->setWidget(view);
            view->setSource(QUrl("qrc:/main1.qml"));
            mainWindow.addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
        }
    
        mainWindow.showMaximized();
        return app.exec();
    }
    

    main1.qml:

    import QtQuick 2.7
    import QtQuick.Controls 2.0
    import QtQuick.Layouts 1.3
    
    Rectangle {
        id: main
        color: "orange"
        Text {
            anchors.horizontalCenter: parent.horizontalCenter
            text: "one"
            SequentialAnimation on font.pixelSize {
                loops: Animation.Infinite
                PropertyAnimation { to: 200 }
                PropertyAnimation { to: 0 }
            }
            SequentialAnimation on y {
                loops: Animation.Infinite
                PropertyAnimation { duration: 1000; to: 1000 }
                PropertyAnimation { duration: 1000; to: 0 }
            }
        }
    }
    

    Here the callstack:

    1  QSGDefaultDistanceFieldGlyphCache::~QSGDefaultDistanceFieldGlyphCache()
    2  QSGDefaultDistanceFieldGlyphCache::~QSGDefaultDistanceFieldGlyphCache()
    3  QSGDefaultRenderContext::invalidate()
    4  QQuickRenderControl::invalidate()
    5  ??
    6  ??
    7  QQuickWidget::event(QEvent *)
    8  QApplicationPrivate::notify_helper(QObject *, QEvent *)
    9  QApplication::notify(QObject *, QEvent *)
    10 QCoreApplication::notifyInternal2(QObject *, QEvent *)
    11 ??
    12 ?? 
    13 QWidget::setParent(QWidget *, QFlags<Qt::WindowType>)
    14 QWidgetPrivate::setWindowFlags(QFlags<Qt::WindowType>)
    15 ??
    16 ??
    17 ??
    18 ??
    19 ??
    20 QDockWidget::event(QEvent *)
    21 QApplicationPrivate::notify_helper(QObject *, QEvent *)
    22 QApplication::notify(QObject *, QEvent *)
    23 QCoreApplication::notifyInternal2(QObject *, QEvent *)
    24 QApplicationPrivate::sendMouseEvent(QWidget *, QMouseEvent *, QWidget *, QWidget *, QWidget * *, QPointer<QWidget>&, bool)
    25 ??
    26 ??
    27 QApplicationPrivate::notify_helper(QObject *, QEvent *)
    28 QApplication::notify(QObject *, QEvent *)
    29 QCoreApplication::notifyInternal2(QObject *, QEvent *)
    30 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *)
    31 QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *)
    32 QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)
    33 ??
    34 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)
    35 QCoreApplication::exec()
    36 main                                                                                                                         
    

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Do you have the same crash if you use your distribution provided Qt ?



  • Hi! Thank you for your question. Yes, if I rebuild the project with the system qt 5.9.5, i have the same behavior : application crashed after i try to detach QDockWidget. Here is the callstack:

    1  ??
    2  QSGDefaultDistanceFieldGlyphCache::~QSGDefaultDistanceFieldGlyphCache()
    3  QSGDefaultDistanceFieldGlyphCache::~QSGDefaultDistanceFieldGlyphCache()
    4  QSGDistanceFieldGlyphCacheManager::~QSGDistanceFieldGlyphCacheManager()
    5  QSGDefaultRenderContext::invalidate()
    6  QQuickRenderControl::invalidate()
    7  ??
    8  ??
    9  QQuickWidget::event(QEvent *)
    10 QApplicationPrivate::notify_helper(QObject *, QEvent *)
    11 QApplication::notify(QObject *, QEvent *)
    12 QCoreApplication::notifyInternal2(QObject *, QEvent *)
    13 ??
    14 ??
    15 QWidget::setParent(QWidget *, QFlags<Qt::WindowType>)
    16 QWidgetPrivate::setWindowFlags(QFlags<Qt::WindowType>)
    17 ??
    18 ??
    19 ??
    20 ??
    21 ??
    22 QDockWidget::event(QEvent *)
    23 QApplicationPrivate::notify_helper(QObject *, QEvent *)
    24 QApplication::notify(QObject *, QEvent *)
    25 QCoreApplication::notifyInternal2(QObject *, QEvent *)
    26 QApplicationPrivate::sendMouseEvent(QWidget *, QMouseEvent *, QWidget *, QWidget *, QWidget * *, QPointer<QWidget>&, bool)
    27 ??
    28 ??
    29 QApplicationPrivate::notify_helper(QObject *, QEvent *)
    30 QApplication::notify(QObject *, QEvent *)
    31 QCoreApplication::notifyInternal2(QObject *, QEvent *)
    32 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *)
    33 QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *)
    34 QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)
    35 ??
    36 g_main_context_dispatch
    37 ??
    38 g_main_context_iteration
    39 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)
    40 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)
    41 QCoreApplication::exec()
    42 main                         main.cpp 38
    

  • Lifetime Qt Champion

    I tested your application with Qt 5.11.2 on macOS and it's working properly.



  • I am sorry, it must be something wrong with my installation. This problem exist in KDE desktop, but after i switched to Gnome, all works fine. Thank you.


Log in to reply