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

QWidget::setParent(QWidget*) should behave the same as QWdiget::setParent(QWidget, Qt::WindowFlags)

    XMLWordPrintable

Details

    • d73497cf770c92e38903850267fd8737df3578ca

    Description

      Sometimes calls to widget->setParent(parent_widget, flags) goes into an infinite recursion inside libQt5Widgets.so.5. I haven't tracked down what happens yet, I haven't found a way to reproduce it, but it might be that widget->parentWidget()==parent_widget.

       

      You do check for this condition (widget->parentWidget()==parent_widget) in QWidget::setParent(QWidget*): https://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/kernel/qwidget.cpp#n10298), but not in QWidget::setParent(QWidget*, Qt::WindowFlags): https://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/kernel/qwidget.cpp#n10326

       

      I suggest moving the check in setParent(QWidget*) to setParent(QWidget*, Qt::WindowFlags). At least, both methods should behave the same.

       

      Attachments

        1. test.cpp
          0.6 kB
          Kjetil Matheussen
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            kmatheussen Kjetil Matheussen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes