From c208b648f91da5139b8eda0c239201768f9d4059 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 8 Jun 2020 16:48:15 +0200 Subject: [PATCH] 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 --- src/corelib/global/qglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 31f482dd8d0..f2e8cae4ae5 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 inline T *qGetPtrHelper(T *ptr) { return ptr; } -template inline auto qGetPtrHelper(Ptr &ptr) -> decltype(ptr.operator->()) { return ptr.operator->(); } +template 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