diff options
| author | David Faure <faure@kde.org> | 2015-04-04 13:40:21 +0200 | 
|---|---|---|
| committer | David Faure <faure@kde.org> | 2015-04-04 13:44:01 +0200 | 
| commit | ee599bfa17f7e56b0db1a4afbbfe929ec90f2c9d (patch) | |
| tree | eef98e45e0714e13dde055e9a684290588d97dc8 /src | |
| parent | 731a9b83f4bd1f2dc840cfae84edcd0b533810aa (diff) | |
| download | kconfig-ee599bfa17f7e56b0db1a4afbbfe929ec90f2c9d.tar.gz kconfig-ee599bfa17f7e56b0db1a4afbbfe929ec90f2c9d.tar.bz2 | |
KConfig: fix using KSharedConfig in global object destructor.
ksharedconfig_in_global_object.cpp is now in kdelibs4 too
(where it works) and reproduces Albert's KgDifficulty testcase.
CHANGELOG: fix assert when using KSharedConfig in a global object destructor.
REVIEW: 122232
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/kconfig.cpp | 20 | 
1 files changed, 16 insertions, 4 deletions
| diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 1da816fa..3819716b 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -530,23 +530,35 @@ KConfig::OpenFlags KConfig::openFlags() const      return d->openFlags;  } -Q_GLOBAL_STATIC(QString, globalMainConfigName) +struct KConfigStaticData +{ +    QString globalMainConfigName; +    // Keep a copy so we can use it in global dtors, after qApp is gone +    // This is a workaround for the Qt bug fixed in https://codereview.qt-project.org/107005 for Qt 5.5 +    // Revert this addition once we can depend on Qt 5.5. +    QStringList appArgs; +}; +Q_GLOBAL_STATIC(KConfigStaticData, globalData)  void KConfig::setMainConfigName(const QString &str)  { -    *globalMainConfigName() = str; +    globalData()->globalMainConfigName = str;  }  QString KConfig::mainConfigName()  { +    KConfigStaticData* data = globalData(); +    if (data->appArgs.isEmpty()) +        data->appArgs = QCoreApplication::arguments(); +      // --config on the command line overrides everything else -    const QStringList args = QCoreApplication::arguments(); +    const QStringList args = data->appArgs;      for (int i = 1; i < args.count(); ++i) {          if (args.at(i) == QLatin1String("--config") && i < args.count() - 1) {              return args.at(i + 1);          }      } -    const QString globalName = *globalMainConfigName(); +    const QString globalName = data->globalMainConfigName;      if (!globalName.isEmpty()) {          return globalName;      } | 
