mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-24 19:02:51 +00:00
ktimezoned: prioritize symlink strategy
if opening symlink via QFile does not fail no signal for config change would be emited if it was symlink unless is replaced with actual file Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
4aec21fdb5
commit
21d9b63bf1
1 changed files with 14 additions and 20 deletions
|
@ -267,19 +267,20 @@ void KTimeZoned::findLocalZone()
|
||||||
if (!mLocalZone.isEmpty()) kDebug(1221)<<"TZ: "<<mLocalZone;
|
if (!mLocalZone.isEmpty()) kDebug(1221)<<"TZ: "<<mLocalZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mLocalZone.isEmpty()) {
|
|
||||||
// SOLUTION 2: DEFINITIVE.
|
|
||||||
// BSD & Linux support: local time zone id in /etc/timezone.
|
|
||||||
checkTimezone();
|
|
||||||
}
|
|
||||||
if (mLocalZone.isEmpty() && !mZoneinfoDir.isEmpty()) {
|
if (mLocalZone.isEmpty() && !mZoneinfoDir.isEmpty()) {
|
||||||
// SOLUTION 3: DEFINITIVE.
|
// SOLUTION 2: DEFINITIVE.
|
||||||
// Try to follow any /etc/localtime symlink to a zoneinfo file.
|
// Try to follow any /etc/localtime symlink to a zoneinfo file.
|
||||||
// SOLUTION 4: DEFINITIVE.
|
// SOLUTION 3: DEFINITIVE.
|
||||||
// Try to match /etc/localtime against the list of zoneinfo files.
|
// Try to match /etc/localtime against the list of zoneinfo files.
|
||||||
matchZoneFile(QLatin1String("/etc/localtime"));
|
matchZoneFile(QLatin1String("/etc/localtime"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mLocalZone.isEmpty()) {
|
||||||
|
// SOLUTION 4: DEFINITIVE.
|
||||||
|
// BSD & Linux support: local time zone id in /etc/timezone.
|
||||||
|
checkTimezone();
|
||||||
|
}
|
||||||
|
|
||||||
if (mLocalZone.isEmpty()) {
|
if (mLocalZone.isEmpty()) {
|
||||||
// The local time zone is not defined by a file.
|
// The local time zone is not defined by a file.
|
||||||
// Watch for creation of /etc/localtime in case it gets created later.
|
// Watch for creation of /etc/localtime in case it gets created later.
|
||||||
|
@ -356,23 +357,16 @@ void KTimeZoned::zonetab_Changed(const QString& path)
|
||||||
// Called when KDirWatch detects a change
|
// Called when KDirWatch detects a change
|
||||||
void KTimeZoned::localChanged()
|
void KTimeZoned::localChanged()
|
||||||
{
|
{
|
||||||
const char *envtz = ::getenv("TZ");
|
QByteArray envTz = qgetenv("TZ");
|
||||||
if (mSavedTZ != envtz) {
|
|
||||||
// TZ has changed - start from scratch again
|
|
||||||
findLocalZone();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFileInfo info(mLocalIdFile);
|
QFileInfo info(mLocalIdFile);
|
||||||
QDateTime currentstamp = info.lastModified();
|
QDateTime currentstamp = info.lastModified();
|
||||||
if (currentstamp == mLocalStamp)
|
if (currentstamp == mLocalStamp && mSavedTZ == envTz)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mLocalStamp = currentstamp;
|
mLocalStamp = currentstamp;
|
||||||
matchZoneFile(mLocalIdFile);
|
mSavedTZ = envTz;
|
||||||
checkTimezone();
|
|
||||||
|
|
||||||
updateLocalZone();
|
findLocalZone();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KTimeZoned::checkTZ(const char *envZone)
|
bool KTimeZoned::checkTZ(const char *envZone)
|
||||||
|
@ -445,7 +439,7 @@ bool KTimeZoned::checkTimezone()
|
||||||
|
|
||||||
bool KTimeZoned::matchZoneFile(const QString &path)
|
bool KTimeZoned::matchZoneFile(const QString &path)
|
||||||
{
|
{
|
||||||
// SOLUTION 3: DEFINITIVE.
|
// SOLUTION 2: DEFINITIVE.
|
||||||
// Try to follow any symlink to a zoneinfo file.
|
// Try to follow any symlink to a zoneinfo file.
|
||||||
// Get the path of the file which the symlink points to.
|
// Get the path of the file which the symlink points to.
|
||||||
QFile f;
|
QFile f;
|
||||||
|
@ -475,7 +469,7 @@ bool KTimeZoned::matchZoneFile(const QString &path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (f.open(QIODevice::ReadOnly)) {
|
else if (f.open(QIODevice::ReadOnly)) {
|
||||||
// SOLUTION 4: DEFINITIVE.
|
// SOLUTION 3: DEFINITIVE.
|
||||||
// Try to match the file against the list of zoneinfo files.
|
// Try to match the file against the list of zoneinfo files.
|
||||||
|
|
||||||
KTimeZone local;
|
KTimeZone local;
|
||||||
|
|
Loading…
Add table
Reference in a new issue