JObjectBase: make all SMFs protected

This is safer against slicing and more explicit, ie. doesn't leave
readers of the code wondering whether the JObject move SMFs are
actually working or call something else, because the JObjectBase move
SMFs are disabled due to the protected dtor.

Change-Id: I5c94c95c2e2b807a8ea3bfbcc2b80b390b2bd837
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 51c5259fe9c5f5e41a22622830f1ca532f989685)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-06-12 08:52:21 +02:00 committed by Qt Cherry-pick Bot
parent 5280f307a8
commit 294f257a0a

View File

@ -685,6 +685,10 @@ struct QT_TECH_PREVIEW_API JObjectBase
protected:
JObjectBase() = default;
JObjectBase(const JObjectBase &) = default;
JObjectBase(JObjectBase &&) = default;
JObjectBase &operator=(const JObjectBase &) = default;
JObjectBase &operator=(JObjectBase &&) = default;
~JObjectBase() = default;
Q_IMPLICIT JObjectBase(jobject object) : m_object(object) {}
@ -707,7 +711,7 @@ public:
Q_IMPLICIT JObject(const QJniObject &object) : JObjectBase(object) {}
Q_IMPLICIT JObject(QJniObject &&object) noexcept : JObjectBase(std::move(object)) {}
// base class destructor is protected, so need to provide all SMFs
// base class SMFs are protected, make them public:
JObject(const JObject &other) = default;
JObject(JObject &&other) noexcept = default;
JObject &operator=(const JObject &other) = default;