aboutsummaryrefslogtreecommitdiff
path: root/launcher/QObjectPtr.h
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/QObjectPtr.h')
-rw-r--r--launcher/QObjectPtr.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/launcher/QObjectPtr.h b/launcher/QObjectPtr.h
index b1ef1c8d..a1c64b43 100644
--- a/launcher/QObjectPtr.h
+++ b/launcher/QObjectPtr.h
@@ -20,18 +20,34 @@ using unique_qobject_ptr = QScopedPointer<T, QScopedPointerDeleteLater>;
template <typename T>
class shared_qobject_ptr : public QSharedPointer<T> {
public:
- constexpr shared_qobject_ptr() : QSharedPointer<T>() {}
- constexpr shared_qobject_ptr(T* ptr) : QSharedPointer<T>(ptr, &QObject::deleteLater) {}
+ constexpr explicit shared_qobject_ptr() : QSharedPointer<T>() {}
+ constexpr explicit shared_qobject_ptr(T* ptr) : QSharedPointer<T>(ptr, &QObject::deleteLater) {}
constexpr shared_qobject_ptr(std::nullptr_t null_ptr) : QSharedPointer<T>(null_ptr, &QObject::deleteLater) {}
template <typename Derived>
constexpr shared_qobject_ptr(const shared_qobject_ptr<Derived>& other) : QSharedPointer<T>(other)
{}
+ template <typename Derived>
+ constexpr shared_qobject_ptr(const QSharedPointer<Derived>& other) : QSharedPointer<T>(other)
+ {}
+
void reset() { QSharedPointer<T>::reset(); }
+ void reset(T*&& other)
+ {
+ shared_qobject_ptr<T> t(other);
+ this->swap(t);
+ }
void reset(const shared_qobject_ptr<T>& other)
{
shared_qobject_ptr<T> t(other);
this->swap(t);
}
};
+
+template <typename T, typename... Args>
+shared_qobject_ptr<T> makeShared(Args... args)
+{
+ auto obj = new T(args...);
+ return shared_qobject_ptr<T>(obj);
+}