From fe88ab0f5dab91597ec7916fd815c6d6864647f7 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Tue, 27 Aug 2024 14:32:46 +0200 Subject: [PATCH] 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 Reviewed-by: Marc Mutz (cherry picked from commit 405cee34297f3cf2a822658ba14922dfaaa8429d) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/kernel/qjniobject.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qjniobject.h b/src/corelib/kernel/qjniobject.h index c84effc160c..2f6cb71223a 100644 --- a/src/corelib/kernel/qjniobject.h +++ b/src/corelib/kernel/qjniobject.h @@ -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 struct Traits> {