aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@theqtcompany.com>2015-02-16 14:36:44 +0100
committerChristian Stromme <christian.stromme@theqtcompany.com>2015-03-02 13:52:01 +0000
commit4eb51defe10f4b97a3b6107ed4080311c0876a65 (patch)
tree49760feed20fba71c7463c859233bcd8f3a87743 /src
parentecd7db7ff28c3dae943ea364464ee8941e36c4c7 (diff)
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 <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/androidextras/jni/qandroidjniobject.h28
1 files changed, 7 insertions, 21 deletions
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 <typename T> friend bool operator!=(const QAndroidJniObject &, T);
- template <typename T> friend bool operator==(const QAndroidJniObject &, T);
- template <typename T> friend bool operator!=(T, const QAndroidJniObject &);
- template <typename T> friend bool operator==(T, const QAndroidJniObject &);
+ template <typename T> friend bool operator!=(const QAndroidJniObject &, const QAndroidJniObject &);
+ template <typename T> 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 <typename T>
-inline bool operator==(const QAndroidJniObject &obj1, T obj2)
-{
- return obj1.isSameObject(static_cast<jobject>(obj2));
-}
-
-template <typename T>
-inline bool operator==(T obj1, const QAndroidJniObject &obj2)
-{
- return obj2.isSameObject(static_cast<jobject>(obj1));
-}
-
-template <typename T>
-inline bool operator!=(const QAndroidJniObject &obj1, T obj2)
+template<typename T>
+inline bool operator==(const QAndroidJniObject &obj1, const QAndroidJniObject &obj2)
{
- return !obj1.isSameObject(static_cast<jobject>(obj2));
+ return obj1.isSameObject(obj2.object());
}
template <typename T>
-inline bool operator!=(T obj1, const QAndroidJniObject &obj2)
+inline bool operator!=(const QAndroidJniObject &obj1, const QAndroidJniObject &obj2)
{
- return !obj2.isSameObject(static_cast<jobject>(obj1));
+ return !obj1.isSameObject(obj2.object());
}
QT_END_NAMESPACE