28 #include "qtprotobufglobal.h"
33 #include <type_traits>
42 QObject::disconnect(m_destroyed);
45 typename std::add_lvalue_reference<T>::type operator *()
const {
46 if (m_ptr ==
nullptr) {
52 T *operator->()
const noexcept {
53 if (m_ptr ==
nullptr) {
60 if (m_ptr ==
nullptr) {
67 return (m_ptr ==
nullptr && other.m_ptr ==
nullptr)
68 || (other.m_ptr ==
nullptr && *m_ptr == T{})
69 || (m_ptr ==
nullptr && *other.m_ptr == T{})
70 || (m_ptr !=
nullptr && other.m_ptr !=
nullptr && *m_ptr == *other.m_ptr);
74 return !operator ==(other);
77 void reset(T *p)
const {
79 QObject::disconnect(m_destroyed);
80 m_destroyed = QObject::connect(p, &QObject::destroyed, [
this] {
81 QObject::disconnect(m_destroyed);
90 m_ptr = std::move(other.m_ptr);
93 explicit operator bool() const noexcept {
94 return m_ptr.operator bool();
98 void checkAndRelease()
const {
99 if (m_ptr !=
nullptr && QQmlEngine::objectOwnership(m_ptr.get()) == QQmlEngine::JavaScriptOwnership) {
101 QObject::disconnect(m_destroyed);
107 mutable std::unique_ptr<T> m_ptr;
108 mutable QMetaObject::Connection m_destroyed;
Definition: qprotobuflazymessagepointer.h:36