From 4eb51defe10f4b97a3b6107ed4080311c0876a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Mon, 16 Feb 2015 14:36:44 +0100 Subject: Fix comparison overloads. The templated comparison overloads could cause build errors due to overload resolution being ambiguous; since implicit conversion from jni object types to QAndroidJniObject is allowed the operator could end up competing with built in types. To avoid that we get this ambiguity both arguments of the operators will now require a QAndroidJniObject, this effectively disables the templated operators unless called directly. Since the templated operator overloads does not export any symbols and are still callable, we retain both SC* and BC. *Code that is written after this change, that would otherwise be affected by this bug, will of course not be able to move back to an older version. Task-number: QTBUG-43453 Change-Id: Icc774c432d078aeb7eb80ccbd0c25196af5f5a51 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/androidextras/jni/qandroidjniobject.h | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/androidextras/jni/qandroidjniobject.h b/src/androidextras/jni/qandroidjniobject.h index c411053..e828f80 100644 --- a/src/androidextras/jni/qandroidjniobject.h +++ b/src/androidextras/jni/qandroidjniobject.h @@ -159,10 +159,8 @@ public: private: friend bool operator==(const QAndroidJniObject &, const QAndroidJniObject &); friend bool operator!=(const QAndroidJniObject &, const QAndroidJniObject &); - template friend bool operator!=(const QAndroidJniObject &, T); - template friend bool operator==(const QAndroidJniObject &, T); - template friend bool operator!=(T, const QAndroidJniObject &); - template friend bool operator==(T, const QAndroidJniObject &); + template friend bool operator!=(const QAndroidJniObject &, const QAndroidJniObject &); + template friend bool operator==(const QAndroidJniObject &, const QAndroidJniObject &); QAndroidJniObject(const QJNIObjectPrivate &o); @@ -184,28 +182,16 @@ inline bool operator!=(const QAndroidJniObject &obj1, const QAndroidJniObject &o return !obj1.isSameObject(obj2); } -template -inline bool operator==(const QAndroidJniObject &obj1, T obj2) -{ - return obj1.isSameObject(static_cast(obj2)); -} - -template -inline bool operator==(T obj1, const QAndroidJniObject &obj2) -{ - return obj2.isSameObject(static_cast(obj1)); -} - -template -inline bool operator!=(const QAndroidJniObject &obj1, T obj2) +template +inline bool operator==(const QAndroidJniObject &obj1, const QAndroidJniObject &obj2) { - return !obj1.isSameObject(static_cast(obj2)); + return obj1.isSameObject(obj2.object()); } template -inline bool operator!=(T obj1, const QAndroidJniObject &obj2) +inline bool operator!=(const QAndroidJniObject &obj1, const QAndroidJniObject &obj2) { - return !obj2.isSameObject(static_cast(obj1)); + return !obj1.isSameObject(obj2.object()); } QT_END_NAMESPACE -- cgit v1.2.3