QWidget: DRY the ctors, use ctor delegation

Don't repeat the body in the two QWidgets ctors, call one from the
other instead.

This will help fighting Coverity's hallucination that QWidget::data is
used uninitialized, or, after 58b9250aea0b1b41c8cbd1033149371a93a5b2c1,
dereferenced while it's still nullptr.

Coverity-Id: 475552
Coverity-Id: 475551
Coverity-Id: 475550
Coverity-Id: 475549
Coverity-Id: 396828
Pick-to: 6.8 6.5
Change-Id: I1f9a8b93871143b420b9c8f247e49d57510a2379
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 66268742861c3eb9b3d97c2758a1babbae850e1f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2025-03-03 10:53:04 +01:00 committed by Qt Cherry-pick Bot
parent de3cf05b77
commit 5ad97482a9

View File

@ -853,14 +853,8 @@ struct QWidgetExceptionCleaner
\sa windowFlags
*/
QWidget::QWidget(QWidget *parent, Qt::WindowFlags f)
: QObject(*new QWidgetPrivate, nullptr), QPaintDevice()
: QWidget(*new QWidgetPrivate, parent, f)
{
QT_TRY {
d_func()->init(parent, f);
} QT_CATCH(...) {
QWidgetExceptionCleaner::cleanup(this, d_func());
QT_RETHROW;
}
}