diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-06-08 16:48:15 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-06-10 02:46:42 +0200 |
commit | c208b648f91da5139b8eda0c239201768f9d4059 (patch) | |
tree | 0379124328111c7c5db90dfe0c30589b57c02966 /src | |
parent | d7c75ee005cc73bb74f0efe1171c7d3c08328fb1 (diff) |
qGetPtrHelper: make it work with null d-pointers
operator-> comes with the precondition that the smart pointer
is not null. Having null d-pointers is a valid use case, so
enable it by using get() instead of operator->().
Change-Id: I78d77ca8c44e92a65ca98b15d0620bc3a1917ad2
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/global/qglobal.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 31f482dd8d..f2e8cae4ae 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1086,7 +1086,7 @@ for (auto _container_ = QtPrivate::qMakeForeachContainer(container); \ #endif template <typename T> inline T *qGetPtrHelper(T *ptr) { return ptr; } -template <typename Ptr> inline auto qGetPtrHelper(Ptr &ptr) -> decltype(ptr.operator->()) { return ptr.operator->(); } +template <typename Ptr> inline auto qGetPtrHelper(Ptr &ptr) -> decltype(ptr.get()) { return ptr.get(); } // The body must be a statement: #define Q_CAST_IGNORE_ALIGN(body) QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wcast-align") body QT_WARNING_POP |