Fix mis-guided init() in default QAndroidTimeZonePrivate constructor

It set the time-zone member sensibly to the default zone, but then
called init("UTC"), which over-wrote that default with UTC.  This had
no visible effect (as the default-constructed object is only used to
access methods that (though virtual) are effectively static), but was
needlessly complicated.

Tidied up systemTimeZoneId() at the same time.

Change-Id: I897aff16855c28487a1029bef50c75ebc1ff5b55
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Edward Welbourne 2019-11-26 13:35:10 +01:00
parent c20c7efea9
commit 78cde1bfd9
1 changed files with 8 additions and 8 deletions

View File

@ -54,9 +54,10 @@ QT_BEGIN_NAMESPACE
QAndroidTimeZonePrivate::QAndroidTimeZonePrivate()
: QTimeZonePrivate()
{
// start with system time zone
androidTimeZone = QJNIObjectPrivate::callStaticObjectMethod("java.util.TimeZone", "getDefault", "()Ljava/util/TimeZone;");
init("UTC");
// Keep in sync with systemTimeZoneId():
androidTimeZone = QJNIObjectPrivate::callStaticObjectMethod(
"java.util.TimeZone", "getDefault", "()Ljava/util/TimeZone;");
m_id = androidTimeZone.callObjectMethod("getID", "()Ljava/lang/String;").toString().toUtf8();
}
// Create a named time zone
@ -227,11 +228,10 @@ QTimeZonePrivate::Data QAndroidTimeZonePrivate::previousTransition(qint64 before
QByteArray QAndroidTimeZonePrivate::systemTimeZoneId() const
{
QJNIObjectPrivate androidSystemTimeZone = QJNIObjectPrivate::callStaticObjectMethod("java.util.TimeZone", "getDefault", "()Ljava/util/TimeZone;");
QJNIObjectPrivate systemTZIdAndroid = androidSystemTimeZone.callObjectMethod<jstring>("getID");
QByteArray systemTZid = systemTZIdAndroid.toString().toUtf8();
return systemTZid;
// Keep in sync with default constructor:
QJNIObjectPrivate androidSystemTimeZone = QJNIObjectPrivate::callStaticObjectMethod(
"java.util.TimeZone", "getDefault", "()Ljava/util/TimeZone;");
return androidSystemTimeZone.callObjectMethod<jstring>("getID").toString().toUtf8();
}
QList<QByteArray> QAndroidTimeZonePrivate::availableTimeZoneIds() const