diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index af0c0ed336..4acec9c1f6 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -95,7 +95,6 @@ typedef QScopedPointerObjectDeleteLater QScopedPointerDeleteLater; template > class QScopedPointer { - typedef T *QScopedPointer:: *RestrictedBool; public: explicit QScopedPointer(T *p = nullptr) noexcept : d(p) { @@ -123,17 +122,10 @@ public: return !d; } -#if defined(Q_QDOC) - inline operator bool() const + explicit operator bool() const { - return isNull() ? nullptr : &QScopedPointer::d; + return !isNull(); } -#else - operator RestrictedBool() const noexcept - { - return isNull() ? nullptr : &QScopedPointer::d; - } -#endif T *data() const noexcept { diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 235cbe144b..35058a1c6e 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -283,7 +283,6 @@ namespace QtSharedPointer { template class QSharedPointer { - typedef T *QSharedPointer:: *RestrictedBool; typedef QtSharedPointer::ExternalRefCountData Data; template using IfCompatible = typename std::enable_if::value, bool>::type; @@ -301,7 +300,7 @@ public: T *data() const noexcept { return value; } T *get() const noexcept { return value; } bool isNull() const noexcept { return !data(); } - operator RestrictedBool() const noexcept { return isNull() ? nullptr : &QSharedPointer::value; } + explicit operator bool() const noexcept { return !isNull(); } bool operator !() const noexcept { return isNull(); } T &operator*() const { return *data(); } T *operator->() const noexcept { return data(); } @@ -539,7 +538,6 @@ public: template class QWeakPointer { - typedef T *QWeakPointer:: *RestrictedBool; typedef QtSharedPointer::ExternalRefCountData Data; template using IfCompatible = typename std::enable_if::value, bool>::type; @@ -554,7 +552,7 @@ public: typedef qptrdiff difference_type; bool isNull() const noexcept { return d == nullptr || d->strongref.loadRelaxed() == 0 || value == nullptr; } - operator RestrictedBool() const noexcept { return isNull() ? nullptr : &QWeakPointer::value; } + explicit operator bool() const noexcept { return !isNull(); } bool operator !() const noexcept { return isNull(); } #if QT_DEPRECATED_SINCE(5, 14) diff --git a/src/opengl/qopengltextureblitter.cpp b/src/opengl/qopengltextureblitter.cpp index b350e8e0e3..0f389547cc 100644 --- a/src/opengl/qopengltextureblitter.cpp +++ b/src/opengl/qopengltextureblitter.cpp @@ -440,7 +440,7 @@ bool QOpenGLTextureBlitter::create() bool QOpenGLTextureBlitter::isCreated() const { Q_D(const QOpenGLTextureBlitter); - return d->programs[QOpenGLTextureBlitterPrivate::TEXTURE_2D].glProgram; + return !d->programs[QOpenGLTextureBlitterPrivate::TEXTURE_2D].glProgram.isNull(); } /*! diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.h b/src/plugins/platforms/windows/qwindowsdialoghelpers.h index 8686749011..55167ad36d 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.h +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.h @@ -80,7 +80,7 @@ public: protected: QWindowsDialogHelperBase() = default; QWindowsNativeDialogBase *nativeDialog() const; - inline bool hasNativeDialog() const { return m_nativeDialog; } + inline bool hasNativeDialog() const { return !m_nativeDialog.isNull(); } void timerEvent(QTimerEvent *) override; private: