QtJniTypes::JObject: fix comparison operators

The comparesEqual() helper method cannot be noexcept, because the
comparison operators of the underlying QJniObject are not, and
cannot readily be made noexcept, because they end up calling JNI
stuff like jniEnv()->IsSameObject().

Also, the *_LITERAL_TYPE helper macro should be used only if the
operators are constexpr, which is also not correct in this case.

Remove the noexcept specifier from the helper method and use the
*_NON_NOEXCEPT version of the comparison helper macro.

This change is picked to 6.8 and 6.7, because the API is marked as
tech preview.
The 6.7 cherry-pick would require a manual fix, because the
*_NON_NOEXCEPT version of the macro didn't exist back then.

Amends a5d14a9f5cfe41784960fe825609d91b9a18c17e.

Pick-to: 6.7
Change-Id: Ic01c0b09f94b94677a9771d1763518697aafc3ef
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 405cee34297f3cf2a822658ba14922dfaaa8429d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ivan Solovev 2024-08-27 14:32:46 +02:00 committed by Qt Cherry-pick Bot
parent d6e8fa64e8
commit fe88ab0f5d

View File

@ -816,9 +816,9 @@ public:
}
private:
friend bool comparesEqual(const JObject &lhs, const JObject &rhs) noexcept
friend bool comparesEqual(const JObject &lhs, const JObject &rhs)
{ return lhs.m_object == rhs.m_object; }
Q_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE(JObject);
Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(JObject);
};
template <typename T> struct Traits<JObject<T>> {