QSharedPointer: Remove support code for tracking weak-pointer
In Qt 6, it is no longer possible to create a weak pointer from a plain
QObject pointer.
Consequently, we don't need the work-aronuds introduced for QTBUG-22622.
Except that we still need to keep the functions as they are exported.
Mark them as QT6_ONLY, so that they'll be gone automatically come Qt 6.
Amends e40320c552.
Change-Id: I568da04008374c891a111eee49f6679dabdfdee4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
parent
25d1db424e
commit
d42b901ae4
|
|
@ -1422,6 +1422,7 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT6_ONLY(
|
||||
/*!
|
||||
\internal
|
||||
This function is called for a just-created QObject \a obj, to enable
|
||||
|
|
@ -1429,7 +1430,9 @@ QT_BEGIN_NAMESPACE
|
|||
*/
|
||||
void QtSharedPointer::ExternalRefCountData::setQObjectShared(const QObject *, bool)
|
||||
{}
|
||||
)
|
||||
|
||||
QT6_ONLY(
|
||||
/*!
|
||||
\internal
|
||||
This function is called when a QSharedPointer is created from a QWeakPointer
|
||||
|
|
@ -1442,6 +1445,7 @@ void QtSharedPointer::ExternalRefCountData::checkQObjectShared(const QObject *)
|
|||
if (strongref.loadRelaxed() < 0)
|
||||
qWarning("QSharedPointer: cannot create a QSharedPointer from a QObject-tracking QWeakPointer");
|
||||
}
|
||||
)
|
||||
|
||||
QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::getAndRef(const QObject *obj)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -116,8 +116,10 @@ namespace QtSharedPointer {
|
|||
|
||||
#ifndef QT_NO_QOBJECT
|
||||
Q_CORE_EXPORT static ExternalRefCountData *getAndRef(const QObject *);
|
||||
QT6_ONLY(
|
||||
Q_CORE_EXPORT void setQObjectShared(const QObject *, bool enable);
|
||||
Q_CORE_EXPORT void checkQObjectShared(const QObject *);
|
||||
)
|
||||
QT6_ONLY(Q_CORE_EXPORT void checkQObjectShared(const QObject *);)
|
||||
#endif
|
||||
inline void checkQObjectShared(...) { }
|
||||
inline void setQObjectShared(...) { }
|
||||
|
|
@ -499,7 +501,6 @@ private:
|
|||
#ifdef QT_SHAREDPOINTER_TRACK_POINTERS
|
||||
internalSafetyCheckAdd(d, ptr);
|
||||
#endif
|
||||
d->setQObjectShared(ptr, true);
|
||||
enableSharedFromThis(ptr);
|
||||
}
|
||||
|
||||
|
|
@ -527,12 +528,10 @@ private:
|
|||
tmp = o->strongref.loadRelaxed(); // failed, try again
|
||||
}
|
||||
|
||||
if (tmp > 0) {
|
||||
if (tmp > 0)
|
||||
o->weakref.ref();
|
||||
} else {
|
||||
o->checkQObjectShared(actual);
|
||||
else
|
||||
o = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
qt_ptr_swap(d, o);
|
||||
|
|
|
|||
Loading…
Reference in New Issue