summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-06-01 00:22:35 +0200
committerMarc Mutz <marc.mutz@kdab.com>2017-02-16 05:02:34 +0000
commit5486882b5253c858cc545cc3a08f0f89af59578e (patch)
tree664168f27e3597a8a5127316529ded142c1b95bc
parentee0edf1b0aa36cfdd5d9628b2bbeb1fb590a3290 (diff)
Android: De-duplicate vtables of exported private classes
By making the destructor (usually the first non-inline, non-pure, virtual function, and therefore the trigger for most compilers to emit the vtable and type_info structures for the class in that TU) out-of-line, vtables and, more importantly, type_info structures for the class are pinned to a single TU. This prevents false-negative dynamic_cast and catch evaluation. Since the classes are already exported, users of these classes are unaffected by the change, and since it's private API, we don't need to avoid adding code to the out-of-line destructor until Qt 6. While at it, de-inline also the empty default implementations of virtual (non-dtor) functions. Task-number: QTBUG-45582 Change-Id: I3e6f37eab1dee0db445f6c13638a43ca3bf6ac62 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp12
-rw-r--r--src/corelib/kernel/qjnihelpers_p.h14
2 files changed, 19 insertions, 7 deletions
diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp
index 6a46f7dd11..091280400e 100644
--- a/src/corelib/kernel/qjnihelpers.cpp
+++ b/src/corelib/kernel/qjnihelpers.cpp
@@ -52,6 +52,18 @@
QT_BEGIN_NAMESPACE
+namespace QtAndroidPrivate {
+ // *Listener virtual function implementations.
+ // Defined out-of-line to pin the vtable/type_info.
+ ActivityResultListener::~ActivityResultListener() {}
+ NewIntentListener::~NewIntentListener() {}
+ ResumePauseListener::~ResumePauseListener() {}
+ void ResumePauseListener::handlePause() {}
+ void ResumePauseListener::handleResume() {}
+ GenericMotionEventListener::~GenericMotionEventListener() {}
+ KeyEventListener::~KeyEventListener() {}
+}
+
static JavaVM *g_javaVM = Q_NULLPTR;
static jobject g_jActivity = Q_NULLPTR;
static jobject g_jService = Q_NULLPTR;
diff --git a/src/corelib/kernel/qjnihelpers_p.h b/src/corelib/kernel/qjnihelpers_p.h
index 478f62a5c7..62f9358513 100644
--- a/src/corelib/kernel/qjnihelpers_p.h
+++ b/src/corelib/kernel/qjnihelpers_p.h
@@ -65,36 +65,36 @@ namespace QtAndroidPrivate
class Q_CORE_EXPORT ActivityResultListener
{
public:
- virtual ~ActivityResultListener() {}
+ virtual ~ActivityResultListener();
virtual bool handleActivityResult(jint requestCode, jint resultCode, jobject data) = 0;
};
class Q_CORE_EXPORT NewIntentListener
{
public:
- virtual ~NewIntentListener() {}
+ virtual ~NewIntentListener();
virtual bool handleNewIntent(JNIEnv *env, jobject intent) = 0;
};
class Q_CORE_EXPORT ResumePauseListener
{
public:
- virtual ~ResumePauseListener() {}
- virtual void handlePause() {};
- virtual void handleResume() {};
+ virtual ~ResumePauseListener();
+ virtual void handlePause();
+ virtual void handleResume();
};
class Q_CORE_EXPORT GenericMotionEventListener
{
public:
- virtual ~GenericMotionEventListener() {}
+ virtual ~GenericMotionEventListener();
virtual bool handleGenericMotionEvent(jobject event) = 0;
};
class Q_CORE_EXPORT KeyEventListener
{
public:
- virtual ~KeyEventListener() {}
+ virtual ~KeyEventListener();
virtual bool handleKeyEvent(jobject event) = 0;
};