diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-06-06 12:52:15 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-06-11 18:44:58 +0200 |
commit | 242bc539ab6d9e76e1f67f2a51918c79970c2788 (patch) | |
tree | 459db17c263ed777c901e8194dc11c31b7ea6081 /src/corelib/kernel/qmetatype.h | |
parent | fafae936a68bac1231b2de69b58e8248ae5dca2f (diff) |
QWeakPointer: use an alternative work-round for internalData() users
The previous work-around fails, probably because of
cross-dependencies. E.g. we have this in QtScXml:
In file included from /home/qt/work/install/include/QtCore/qsharedpointer.h:48:0,
from ../../src/scxml/qscxmltabledata_p.h:55,
from ../../src/scxml/qscxmltabledata.cpp:40:
/home/qt/work/install/include/QtCore/qsharedpointer_impl.h:687:12: error: ‘QPointer’ does not name a type; did you mean ‘pointer’?
friend QPointer<X>
^~~~~~~~
pointer
/home/qt/work/install/include/QtCore/qsharedpointer_impl.h:689:23: error: ‘QSmartPointerConvertFunctor’ in namespace ‘QtPrivate’ does not name a template type
friend QtPrivate::QSmartPointerConvertFunctor<QWeakPointer>;
^~~~~~~~~~~~~~~~~~~~~~~~~~~
To fix, grand friendship only to a non-template class with a templated
static method that returns internalData(). This fixes most users,
except in qmetatype.h, which does not include qsharedpointer.h. In
order to use the non-template class in there, we need to delay its
name lookup to instantiation time. We do this by artificially making
it a dependent name, by using a class template that inherits from
our befrieded class.
Change-Id: I12b427f1fe9503df819ea5436d780972d6402e68
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'src/corelib/kernel/qmetatype.h')
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 154ccf62bb..fef25a32c4 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -1715,12 +1715,17 @@ namespace QtPrivate { } }; + // hack to delay name lookup to instantiation time by making + // EnableInternalData a dependent name: + template <typename T> + struct EnableInternalDataWrap; + template<typename T> struct QSmartPointerConvertFunctor<QWeakPointer<T> > { QObject* operator()(const QWeakPointer<T> &p) const { - return p.internalData(); + return QtPrivate::EnableInternalDataWrap<T>::internalData(p); } }; } |