QObjCWeakPointer: Clear existing associated object on assignment
If the existing m_object is the same as the incoming object the call to objc_setAssociatedObject in trackObjectLifetime will release the existing WeakPointerLifetimeTracker after assigning a new one, which means we'd clear the QObjCWeakPointer's object. We now reset the state up front. Fixes: QTBUG-132256 Pick-to: 6.8 6.9 Change-Id: If2c08840d465ae6d190c87a4720a537fe9caa8dc Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
a56a6ba22d
commit
92012333d1
@ -504,6 +504,9 @@ public:
|
|||||||
QObjCWeakPointer &operator=(const QObjCWeakPointer &other)
|
QObjCWeakPointer &operator=(const QObjCWeakPointer &other)
|
||||||
{
|
{
|
||||||
QMacAutoReleasePool pool;
|
QMacAutoReleasePool pool;
|
||||||
|
#if !USE_OBJC_WEAK
|
||||||
|
objc_setAssociatedObject(m_object, this, nil, OBJC_ASSOCIATION_RETAIN);
|
||||||
|
#endif
|
||||||
m_object = other.m_object;
|
m_object = other.m_object;
|
||||||
#if !USE_OBJC_WEAK
|
#if !USE_OBJC_WEAK
|
||||||
trackObjectLifetime();
|
trackObjectLifetime();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user