Android: Add private ctors in QJNIObjectPrivate that takes va_list.
NewObjectV() was failing because QJNIObject was calling the variadic constructors with a va_list, which in turn created a new va_list. Change-Id: I1cf4c8133f237596964177271a20ca651174e695 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
parent
5bc02ad665
commit
d519b085d1
@ -269,6 +269,24 @@ QJNIObjectPrivate::QJNIObjectPrivate(const char *className, const char *sig, ...
|
||||
}
|
||||
}
|
||||
|
||||
QJNIObjectPrivate::QJNIObjectPrivate(const char *className, const char *sig, va_list args)
|
||||
: d(new QJNIObjectData())
|
||||
{
|
||||
QJNIEnvironmentPrivate env;
|
||||
d->m_jclass = getCachedClass(env, className);
|
||||
d->m_own_jclass = false;
|
||||
if (d->m_jclass) {
|
||||
jmethodID constructorId = getCachedMethodID(env, d->m_jclass, "<init>", sig);
|
||||
if (constructorId) {
|
||||
jobject obj = env->NewObjectV(d->m_jclass, constructorId, args);
|
||||
if (obj) {
|
||||
d->m_jobject = env->NewGlobalRef(obj);
|
||||
env->DeleteLocalRef(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QJNIObjectPrivate::QJNIObjectPrivate(jclass clazz)
|
||||
: d(new QJNIObjectData())
|
||||
{
|
||||
@ -309,6 +327,25 @@ QJNIObjectPrivate::QJNIObjectPrivate(jclass clazz, const char *sig, ...)
|
||||
}
|
||||
}
|
||||
|
||||
QJNIObjectPrivate::QJNIObjectPrivate(jclass clazz, const char *sig, va_list args)
|
||||
: d(new QJNIObjectData())
|
||||
{
|
||||
QJNIEnvironmentPrivate env;
|
||||
if (clazz) {
|
||||
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
|
||||
if (d->m_jclass) {
|
||||
jmethodID constructorId = getCachedMethodID(env, d->m_jclass, "<init>", sig);
|
||||
if (constructorId) {
|
||||
jobject obj = env->NewObjectV(d->m_jclass, constructorId, args);
|
||||
if (obj) {
|
||||
d->m_jobject = env->NewGlobalRef(obj);
|
||||
env->DeleteLocalRef(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QJNIObjectPrivate::QJNIObjectPrivate(jobject obj)
|
||||
: d(new QJNIObjectData())
|
||||
{
|
||||
|
@ -189,6 +189,9 @@ public:
|
||||
private:
|
||||
friend class QJNIObject;
|
||||
|
||||
QJNIObjectPrivate(const char *className, const char *sig, va_list args);
|
||||
QJNIObjectPrivate(jclass clazz, const char *sig, va_list args);
|
||||
|
||||
template <typename T>
|
||||
T callMethod(const char *methodName,
|
||||
const char *sig,
|
||||
|
Loading…
Reference in New Issue
Block a user