diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-10-09 23:35:06 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-10-11 06:52:01 +0200 |
commit | f67481094fa7f16dec281f9a96dd0de3dc0c453f (patch) | |
tree | 907dc97faf61ea9aacb5c736d05574a612a7936b /src | |
parent | f60b9df73d53774f0e83215f41b9cf91cbe09197 (diff) |
QObject: use delegate constructors
Avoid the massive code duplication in the two QObject constructors. The
only slight difference is the code path checking for isWidget; I'd say
that paying for that one is worth the price of de-duplicating.
Change-Id: I3af749738fe7d6b7adf287009d1815396a2f1407
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index fb0d54c801..bb1b48b0a6 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -906,30 +906,8 @@ static bool check_parent_thread(QObject *parent, */ QObject::QObject(QObject *parent) - : d_ptr(new QObjectPrivate) + : QObject(*new QObjectPrivate, parent) { - Q_ASSERT_X(this != parent, Q_FUNC_INFO, "Cannot parent a QObject to itself"); - - Q_D(QObject); - d_ptr->q_ptr = this; - d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current(); - d->threadData->ref(); - if (parent) { - QT_TRY { - if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData)) - parent = 0; - setParent(parent); - } QT_CATCH(...) { - d->threadData->deref(); - QT_RETHROW; - } - } -#if QT_VERSION < 0x60000 - qt_addObject(this); -#endif - if (Q_UNLIKELY(qtHookData[QHooks::AddQObject])) - reinterpret_cast<QHooks::AddQObjectCallback>(qtHookData[QHooks::AddQObject])(this); - Q_TRACE(QObject_ctor, this); } /*! |