Use templated QJniObject::object() instead of static_cast
Change-Id: I3bf366967d7995621aba1a7c1bec6732f3ef957d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
ca14ed494c
commit
c4961c0fbe
@ -96,9 +96,9 @@ static QJniObject getDisplayName(QJniObject zone, jint style, jboolean dst,
|
|||||||
jvariant = QJniObject::fromString(QLocale::scriptToString(locale.script()));
|
jvariant = QJniObject::fromString(QLocale::scriptToString(locale.script()));
|
||||||
QJniObject jlocale("java.util.Locale",
|
QJniObject jlocale("java.util.Locale",
|
||||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
|
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
|
||||||
static_cast<jstring>(jlanguage.object()),
|
jlanguage.object<jstring>(),
|
||||||
static_cast<jstring>(jterritory.object()),
|
jterritory.object<jstring>(),
|
||||||
static_cast<jstring>(jvariant.object()));
|
jvariant.object<jstring>());
|
||||||
|
|
||||||
return zone.callObjectMethod("getDisplayName",
|
return zone.callObjectMethod("getDisplayName",
|
||||||
"(ZILjava/util/Locale;)Ljava/lang/String;",
|
"(ZILjava/util/Locale;)Ljava/lang/String;",
|
||||||
@ -110,7 +110,7 @@ void QAndroidTimeZonePrivate::init(const QByteArray &ianaId)
|
|||||||
const QString iana = QString::fromUtf8(ianaId);
|
const QString iana = QString::fromUtf8(ianaId);
|
||||||
androidTimeZone = QJniObject::callStaticObjectMethod(
|
androidTimeZone = QJniObject::callStaticObjectMethod(
|
||||||
"java.util.TimeZone", "getTimeZone", "(Ljava/lang/String;)Ljava/util/TimeZone;",
|
"java.util.TimeZone", "getTimeZone", "(Ljava/lang/String;)Ljava/util/TimeZone;",
|
||||||
static_cast<jstring>(QJniObject::fromString(iana).object()));
|
QJniObject::fromString(iana).object<jstring>());
|
||||||
|
|
||||||
// The ID or display name of the zone we've got, if it looks like what we asked for:
|
// The ID or display name of the zone we've got, if it looks like what we asked for:
|
||||||
const auto match = [iana](const QJniObject &jname) -> QByteArray {
|
const auto match = [iana](const QJniObject &jname) -> QByteArray {
|
||||||
@ -247,14 +247,14 @@ QList<QByteArray> QAndroidTimeZonePrivate::availableTimeZoneIds() const
|
|||||||
QJniObject androidAvailableIdList = QJniObject::callStaticObjectMethod("java.util.TimeZone", "getAvailableIDs", "()[Ljava/lang/String;");
|
QJniObject androidAvailableIdList = QJniObject::callStaticObjectMethod("java.util.TimeZone", "getAvailableIDs", "()[Ljava/lang/String;");
|
||||||
|
|
||||||
QJniEnvironment jniEnv;
|
QJniEnvironment jniEnv;
|
||||||
int androidTZcount = jniEnv->GetArrayLength( static_cast<jarray>(androidAvailableIdList.object()) );
|
int androidTZcount = jniEnv->GetArrayLength(androidAvailableIdList.object<jarray>());
|
||||||
|
|
||||||
// need separate jobject and QJniObject here so that we can delete (DeleteLocalRef) the reference to the jobject
|
// need separate jobject and QJniObject here so that we can delete (DeleteLocalRef) the reference to the jobject
|
||||||
// (or else the JNI reference table fills after 512 entries from GetObjectArrayElement)
|
// (or else the JNI reference table fills after 512 entries from GetObjectArrayElement)
|
||||||
jobject androidTZobject;
|
jobject androidTZobject;
|
||||||
QJniObject androidTZ;
|
QJniObject androidTZ;
|
||||||
for (int i = 0; i < androidTZcount; i++) {
|
for (int i = 0; i < androidTZcount; i++) {
|
||||||
androidTZobject = jniEnv->GetObjectArrayElement( static_cast<jobjectArray>( androidAvailableIdList.object() ), i );
|
androidTZobject = jniEnv->GetObjectArrayElement(androidAvailableIdList.object<jobjectArray>(), i);
|
||||||
androidTZ = androidTZobject;
|
androidTZ = androidTZobject;
|
||||||
availableTimeZoneIdList.append(androidTZ.toString().toUtf8());
|
availableTimeZoneIdList.append(androidTZ.toString().toUtf8());
|
||||||
jniEnv->DeleteLocalRef(androidTZobject);
|
jniEnv->DeleteLocalRef(androidTZobject);
|
||||||
|
@ -91,7 +91,7 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
|
|||||||
"()[Ljava/lang/String;");
|
"()[Ljava/lang/String;");
|
||||||
bool exclude = false;
|
bool exclude = false;
|
||||||
if (exclusionList.isValid()) {
|
if (exclusionList.isValid()) {
|
||||||
jobjectArray listObject = static_cast<jobjectArray>(exclusionList.object());
|
jobjectArray listObject = exclusionList.object<jobjectArray>();
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
QJniObject entry;
|
QJniObject entry;
|
||||||
const int size = env->GetArrayLength(listObject);
|
const int size = env->GetArrayLength(listObject);
|
||||||
|
@ -198,10 +198,10 @@ bool AndroidContentFileEngineIterator::hasNext() const
|
|||||||
QJniObject::fromString(path()).object());
|
QJniObject::fromString(path()).object());
|
||||||
if (objArray.isValid()) {
|
if (objArray.isValid()) {
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
const jsize length = env->GetArrayLength(static_cast<jarray>(objArray.object()));
|
const jsize length = env->GetArrayLength(objArray.object<jarray>());
|
||||||
for (int i = 0; i != length; ++i) {
|
for (int i = 0; i != length; ++i) {
|
||||||
m_entries << QJniObject(env->GetObjectArrayElement(
|
m_entries << QJniObject(env->GetObjectArrayElement(
|
||||||
static_cast<jobjectArray>(objArray.object()), i)).toString();
|
objArray.object<jobjectArray>(), i)).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ namespace QtAndroidClipboard
|
|||||||
if (uris.isValid()) {
|
if (uris.isValid()) {
|
||||||
QList<QUrl> urls;
|
QList<QUrl> urls;
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jobjectArray juris = static_cast<jobjectArray>(uris.object());
|
jobjectArray juris = uris.object<jobjectArray>();
|
||||||
const jint nUris = env->GetArrayLength(juris);
|
const jint nUris = env->GetArrayLength(juris);
|
||||||
urls.reserve(static_cast<int>(nUris));
|
urls.reserve(static_cast<int>(nUris));
|
||||||
for (int i = 0; i < nUris; ++i)
|
for (int i = 0; i < nUris; ++i)
|
||||||
|
@ -147,7 +147,7 @@ public:
|
|||||||
QtAndroid::assets(), QJniObject::fromString(path).object());
|
QtAndroid::assets(), QJniObject::fromString(path).object());
|
||||||
if (files.isValid()) {
|
if (files.isValid()) {
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jobjectArray jFiles = static_cast<jobjectArray>(files.object());
|
jobjectArray jFiles = files.object<jobjectArray>();
|
||||||
const jint nFiles = env->GetArrayLength(jFiles);
|
const jint nFiles = env->GetArrayLength(jFiles);
|
||||||
for (int i = 0; i < nFiles; ++i) {
|
for (int i = 0; i < nFiles; ++i) {
|
||||||
AssetItem item{QJniObject::fromLocalRef(env->GetObjectArrayElement(jFiles, i)).toString()};
|
AssetItem item{QJniObject::fromLocalRef(env->GetObjectArrayElement(jFiles, i)).toString()};
|
||||||
|
@ -70,7 +70,7 @@ QList<QByteArray> fetchSslCertificateData()
|
|||||||
return certificateData;
|
return certificateData;
|
||||||
|
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jobjectArray jcertificates = static_cast<jobjectArray>(certificates.object());
|
jobjectArray jcertificates = certificates.object<jobjectArray>();
|
||||||
const jint nCertificates = env->GetArrayLength(jcertificates);
|
const jint nCertificates = env->GetArrayLength(jcertificates);
|
||||||
certificateData.reserve(static_cast<int>(nCertificates));
|
certificateData.reserve(static_cast<int>(nCertificates));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user