Changeset 425 for trunk/src


Ignore:
Timestamp:
Dec 14, 2009, 9:16:37 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

corelib/io: QSettings: Use IniFormat (plain INI files) when NativeFormat is requested instead of the Open32 registry which is known to be unstable and can be easily corrupted. The old behavior may be restored using the QT_PM_REGISTRY environment variable (#111).

Location:
trunk/src/corelib/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/corelib/io/qsettings.cpp

    r25 r425  
    11361136                         windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator());
    11371137#elif defined(Q_OS_OS2)
    1138         /* Though this code is very similar to the following #else statment,
    1139          * we have to do it separately for OS/2 and leave the original code
    1140          * intact since QDir::separator() returns ":" on Mac OS X while "/" is
    1141          * actually used in the #else below. */
     1138        /* Though this code is very similar to the following #else block, the
     1139         * definition of the "absolute path" is different on OS/2 (see
     1140         * isRelativePath() in qfsfileengine_os2.cpp) so take it into account)*/
    11421141        QString userPath;
    1143         QString env = QLatin1String(getenv("XDG_CONFIG_HOME"));
     1142        QString env = QFile::decodeName(qgetenv("XDG_CONFIG_HOME"));
    11441143        if (env.isEmpty()) {
    11451144            userPath = homePath;
    11461145            userPath += QDir::separator();
    11471146            userPath += QLatin1String(".config");
    1148         } else if (QDir::isAbsolutePath(env)) {
    1149             userPath = env;
    11501147        } else {
    1151             userPath = homePath;
    1152             userPath += QDir::separator();
    1153             userPath += env;
    1154         }
    1155         userPath += QDir::separator();
     1148            userPath = QDir::cleanPath(QDir(homePath).absoluteFilePath(env));
     1149        }
     1150        userPath = QDir::cleanPath(userPath) + QLatin1Char('/');
    11561151
    11571152        pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), userPath);
     
    23862381    \o \c{%HOME%\.config\MySoft\Star Runner.ini}
    23872382    \o \c{%HOME%\.config\MySoft.ini}
    2388     \o \c{<boot_drv>:\OS2\xdg\MySoft\Star Runner.ini}
    2389     \o \c{<boot_drv>:\OS2\xdg\MySoft.ini}
     2383    \o \c{%ETC%\xdg\MySoft\Star Runner.ini}
     2384    \o \c{%ETC%\xdg\MySoft.ini}
    23902385    \endlist
    23912386
     
    34703465    \row    \o{1,2} Mac OS X    \o{1,2} IniFormat               \o UserScope   \o \c $HOME/.config
    34713466    \row                                                        \o SystemScope \o \c /etc/xdg
    3472     \row    \o{1,2} OS/2        \o{1,2} IniFormat               \o UserScope   \o \c $HOME\.config
    3473     \row                                                        \o SystemScope \o \c <boot_drv>:\OS2\xdg
     3467    \row    \o{1,2} OS/2        \o{1,2} IniFormat               \o UserScope   \o \c %HOME%\.config
     3468    \row                                                        \o SystemScope \o \c %ETC%\xdg
    34743469    \endtable
    34753470
     
    34773472    $HOME/Settings) can be overridden by the user by setting the
    34783473    \c XDG_CONFIG_HOME environment variable. The default SystemScope
    3479     paths on Unix, Mac OS X (\c /etc/xdg) and OS/2 (\c <boot_drv>:\OS2\xdg) can
    3480     be overridden when building the Qt library using the \c configure script's
     3474    paths on Unix, Mac OS X (\c /etc/xdg) and OS/2 (\c %ETC%\xdg) can be
     3475    overridden when building the Qt library using the \c configure script's
    34813476    \c
    34823477    --sysconfdir flag (see QLibraryInfo for details).
  • trunk/src/corelib/io/qsettings_os2.cpp

    r399 r425  
    10701070}
    10711071
     1072static QSettings::Format checkFormat(QSettings::Format format)
     1073{
     1074    if (getenv("QT_PM_NO_REGISTRY") != NULL ||
     1075        getenv("QT_PM_REGISTRY") == NULL) {
     1076#if defined(QT_DEBUG)
     1077        if (getenv("QT_PM_NO_REGISTRY") != NULL)
     1078            qDebug("QSettings: WARNING: using plain INI files due to QT_PM_NO_REGISTRY=%s",
     1079                    getenv("QT_PM_NO_REGISTRY"));
     1080#endif
     1081        if (format == QSettings::NativeFormat)
     1082            format = QSettings::IniFormat;
     1083    }
     1084#if defined(QT_DEBUG)
     1085    if (getenv("QT_PM_REGISTRY") != NULL)
     1086        qDebug("QSettings: WARNING: using Open32 registry due to QT_PM_REGISTRY=%s",
     1087                getenv("QT_PM_REGISTRY"));
     1088#endif
     1089
     1090    return format;
     1091}
     1092
    10721093QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, QSettings::Scope scope,
    10731094                                           const QString &organization, const QString &application)
    10741095{
     1096    format = checkFormat(format);
     1097
    10751098    if (format == QSettings::NativeFormat) {
    10761099        return new QOS2SettingsPrivate(scope, organization, application);
     
    10821105QSettingsPrivate *QSettingsPrivate::create(const QString &fileName, QSettings::Format format)
    10831106{
     1107    format = checkFormat(format);
     1108
    10841109    if (format == QSettings::NativeFormat) {
    10851110        return new QOS2SettingsPrivate(fileName);
Note: See TracChangeset for help on using the changeset viewer.