diff --git a/CHANGELOG.md b/CHANGELOG.md index 88e0aa630..5d753e994 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Blinking on resize or Ui updates on screen that have low frame rates. +- Timezones and Windows fix. ### Added - Screen Sharing diff --git a/linphone-app/src/app/App.cpp b/linphone-app/src/app/App.cpp index 7f9d73906..d4ac51f79 100644 --- a/linphone-app/src/app/App.cpp +++ b/linphone-app/src/app/App.cpp @@ -277,21 +277,39 @@ App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true, Mode::U connect(this, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(stateChanged(Qt::ApplicationState))); setWindowIcon(QIcon(Constants::WindowIconPath)); - - char * tz = getenv("TZ"); - if(!tz){// If not set, set the environement variable for uses of mktime from the SDK. + #ifdef Q_OS_WIN - _putenv(("TZ="+QTimeZone::systemTimeZoneId().toStdString()).c_str()); - _tzset(); + char tz[255] = {0}; + size_t envSize = 0; + getenv_s(&envSize, tz, 255, "TZ"); + if (envSize == 0 || tz[0] == '\0') { // If not set, set the environment variable for uses of mktime from the SDK. + long adjustTimezone; + _tzset(); // init timezone variable + auto error = _get_timezone(&adjustTimezone); + if (adjustTimezone != -QTimeZone::systemTimeZone().offsetFromUtc(QDateTime::currentDateTime())) { + QString timeZone = QTimeZone::systemTimeZoneId(); + _putenv(("TZ=" + timeZone.toStdString()).c_str()); + _tzset(); + qInfo() << "Set TimeZone to " << timeZone; + } + } else qInfo() << "Use environment TimeZone:" << tz; #else - QString t = QTimeZone::systemTimeZoneId(); - setenv("TZ", QTimeZone::systemTimeZoneId().toStdString().c_str(), 1); - tzset(); + char *tz = getenv("TZ"); + if (!tz) { // If not set, set the environment variable for uses of mktime from the SDK. + tzset(); // init timezone variable + if (timezone != -QTimeZone::systemTimeZone().offsetFromUtc(QDateTime::currentDateTime())) { + QString timeZone = QTimeZone::systemTimeZoneId(); + setenv("TZ", timeZone.toStdString().c_str(), 1); + tzset(); + qInfo() << "Set TimeZone to " << timeZone; + } + } else qInfo() << "Use environment TimeZone:" << tz; #endif - } - bctbx_set_default_encoding(Constants::LinphoneLocaleEncoding);// Use UTF-8 for internals. Linphone uses UTF-8 so there will be no loss on data with less precise encodings. Qt will do the rest. - - + + // Use UTF-8 for internals. Linphone uses UTF-8 so there will be no loss on + // data with less precise encodings. Qt will do the rest. + bctbx_set_default_encoding(Constants::LinphoneLocaleEncoding); + createParser(); mParser->parse(this->arguments()); // Get configuration for translators diff --git a/linphone-sdk b/linphone-sdk index 578b51d07..393ef125a 160000 --- a/linphone-sdk +++ b/linphone-sdk @@ -1 +1 @@ -Subproject commit 578b51d07b4f361f0462a8a136d8485a5f75c865 +Subproject commit 393ef125a0fbd98ebbecf257888abbbad681cad1