Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-139109

Creating QQuickWidget on dialog within QDialog::exec() causes early exit

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.10.0
    • GUI: Other, Quick: Other
    • None
    • Linux/Wayland

      Running the attached program causes QDialog::exec() to return early and the program to exit. It seems to come from the fact that when the QQuickWidget is created on a delay, it forces the dialog window to be destroyed and created with a new RSI config. This happens around qwidget.cpp:10938:

                      if (existingSurfaceType != surfaceType) {
                          qCDebug(lcWidgetPainting)
                              << "Recreating" << existingWindow
                              << "with current type" << existingSurfaceType
                              << "to support" << surfaceType;
                          const auto windowStateBeforeDestroy = newParentWithWindow->windowState();
                          const auto visibilityBeforeDestroy = newParentWithWindow->isVisible();
                          const auto positionBeforeDestroy = newParentWithWindow->pos();
                          newParentWithWindow->destroy();
                          newParentWithWindow->create();
      

      Using QDialog::open() instead gets around the problem:

      int main(int argc, char **argv) {
          QApplication app{argc, argv};
          Dialog dlg;
          dlg.open();
          QObject::connect(&dlg, &QDialog::finished, [](int i) { qDebug() << "Result:" << i; });
          return app.exec();
      }
      

      This would probably be a suitable workaround for the linked issues as well.

      Backtrace:

      * thread #1, name = 'main', stop reason = breakpoint 1.1
        * frame #0: 0x00007fffd1733f31 libQt6Widgets.so.6`QWidget::setParent(this=0x00005555557f4350, parent=0x00007fffffffdeb0, f=Qt::WindowFlags @ 0x00007fffffffc938) at qwidget.cpp:10938:21
          frame #1: 0x00007fffd1731f0a libQt6Widgets.so.6`QWidgetPrivate::init(this=0x000055555573c0e0, parentWidget=0x00007fffffffdeb0, f=Qt::WindowFlags @ 0x00007fffffffca64) at qwidget.cpp:985:12
          frame #2: 0x00007fffd1731b26 libQt6Widgets.so.6`QWidget::QWidget(this=0x00005555557f4350, dd=0x000055555573c0e0, parent=0x00007fffffffdeb0, f=Qt::WindowFlags @ 0x00007fffffffcac4) at qwidget.cpp:864:12
          frame #3: 0x00007ffff7f91a0b libQt6QuickWidgets.so.6`QQuickWidget::QQuickWidget(this=0x00005555557f4350, parent=0x00007fffffffdeb0) at qquickwidget.cpp:657:7
          frame #4: 0x0000555555557afc main`Dialog::showEvent(QShowEvent*)::'lambda'()::operator()() const + 58
          frame #5: 0x0000555555558125 main`QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, Dialog::showEvent(QShowEvent*)::'lambda'()>::call(Dialog::showEvent(QShowEvent*)::'lambda'()&, void**)::'lambda'()::operator()() const + 31
          frame #6: 0x00005555555581ad main`void QtPrivate::FunctorCallBase::call_internal<void, QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, Dialog::showEvent(QShowEvent*)::'lambda'()>::call(Dialog::showEvent(QShowEvent*)::'lambda'()&, void**)::'lambda'()>(void**, QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, Dialog::showEvent(QShowEvent*)::'lambda'()>::call(Dialog::showEvent(QShowEvent*)::'lambda'()&, void**)::'lambda'()&&) + 40
          frame #7: 0x000055555555816e main`QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, Dialog::showEvent(QShowEvent*)::'lambda'()>::call(Dialog::showEvent(QShowEvent*)::'lambda'()&, void**) + 70
          frame #8: 0x0000555555558103 main`void QtPrivate::FunctorCallable<Dialog::showEvent(QShowEvent*)::'lambda'()>::call<QtPrivate::List<>, void>(Dialog::showEvent(QShowEvent*)::'lambda'()&, void*, void**) + 43
          frame #9: 0x00005555555580bb main`QtPrivate::QCallableObject<Dialog::showEvent(QShowEvent*)::'lambda'(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) + 124
          frame #10: 0x00007fffd0a30602 libQt6Core.so.6`QtPrivate::QSlotObjectBase::call(this=0x0000555555796e70, r=0x00005555555878b0, a=0x00005555557e9138) at qobjectdefs_impl.h:461:51
          frame #11: 0x00007fffd0c1ce7c libQt6Core.so.6`QMetaCallEvent::placeMetaCall(this=0x00005555557e90f0, object=0x00005555555878b0) at qobject.cpp:621:21
          frame #12: 0x00007fffd0c1e9e1 libQt6Core.so.6`QObject::event(this=0x00005555555878b0, e=0x00005555557e90f0) at qobject.cpp:1411:18
          frame #13: 0x00007fffd0d89aa6 libQt6Core.so.6`QThread::event(this=0x00005555555878b0, event=0x00005555557e90f0) at qthread.cpp:1273:25
          frame #14: 0x00007fffd16a33e0 libQt6Widgets.so.6`QApplicationPrivate::notify_helper(this=0x0000555555587630, receiver=0x00005555555878b0, e=0x00005555557e90f0) at qapplication.cpp:3307:26
          frame #15: 0x00007fffd16a72bc libQt6Widgets.so.6`QApplication::notify(this=0x00007fffffffde80, receiver=0x00005555555878b0, e=0x00005555557e90f0) at qapplication.cpp:3257:18
          frame #16: 0x00007fffd0b6e4a9 libQt6Core.so.6`QCoreApplication::notifyInternal2(receiver=0x00005555555878b0, event=0x00005555557e90f0) at qcoreapplication.cpp:1109:18
          frame #17: 0x00007fffd0b6f119 libQt6Core.so.6`QCoreApplication::sendEvent(receiver=0x00005555555878b0, event=0x00005555557e90f0) at qcoreapplication.cpp:1549:12
          frame #18: 0x00007fffd0b7004a libQt6Core.so.6`QCoreApplicationPrivate::sendPostedEvents(receiver=0x0000000000000000, event_type=0, data=0x0000555555587810) at qcoreapplication.cpp:1893:9
          frame #19: 0x00007fffd0b6ef5c libQt6Core.so.6`QCoreApplication::sendPostedEvents(receiver=0x0000000000000000, event_type=0) at qcoreapplication.cpp:1746:5
          frame #20: 0x00007fffd110ff81 libQt6Core.so.6`postEventSourceDispatch(s=0x000055555558a7c0, (null)=0x0000000000000000, (null)=0x0000000000000000) at qeventdispatcher_glib.cpp:246:5
          frame #21: 0x00007fffcb4f7de2 libglib-2.0.so.0`___lldb_unnamed_symbol2573 + 402
          frame #22: 0x00007fffcb5691f8 libglib-2.0.so.0`___lldb_unnamed_symbol2838 + 984
          frame #23: 0x00007fffcb4f8223 libglib-2.0.so.0`g_main_context_iteration + 51
          frame #24: 0x00007fffd110f1bb libQt6Core.so.6`QEventDispatcherGlib::processEvents(this=0x000055555558a840, flags=QEventLoop::ProcessEventsFlags @ 0x00007fffffffdc44) at qeventdispatcher_glib.cpp:399:19
          frame #25: 0x00007fffcd877fb8 libQt6Gui.so.6`QPAEventDispatcherGlib::processEvents(this=0x000055555558a840, flags=QEventLoop::ProcessEventsFlags @ 0x00007fffffffdc74) at qeventdispatcher_glib.cpp:89:34
          frame #26: 0x00007fffd0b87cb0 libQt6Core.so.6`QEventLoop::processEvents(this=0x00007fffffffde08, flags=QEventLoop::ProcessEventsFlags @ 0x00007fffffffdcc4) at qeventloop.cpp:104:55
          frame #27: 0x00007fffd0b87f03 libQt6Core.so.6`QEventLoop::exec(this=0x00007fffffffde08, flags=QEventLoop::ProcessEventsFlags @ 0x00007fffffffdd7c) at qeventloop.cpp:186:9
          frame #28: 0x00007fffd1b16490 libQt6Widgets.so.6`QDialog::exec(this=0x00007fffffffdeb0) at qdialog.cpp:575:26
          frame #29: 0x000055555555751d main`main + 145
          frame #30: 0x00007fffcfe2a578 libc.so.6`__libc_start_call_main(main=(main`main), argc=1, argv=0x00007fffffffe018) at libc_start_call_main.h:58:16
          frame #31: 0x00007fffcfe2a63b libc.so.6`__libc_start_main_impl(main=(main`main), argc=1, argv=0x00007fffffffe018, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffe008) at libc-start.c:360:3
          frame #32: 0x00005555555572e5 main`_start + 37
      

        1. CMakeLists.txt
          0.2 kB
        2. main.cpp
          0.4 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            moheim Moss Heim
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes