summaryrefslogtreecommitdiff
path: root/qmake/tools/qsettings.cpp
Side-by-side diff
Diffstat (limited to 'qmake/tools/qsettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/tools/qsettings.cpp371
1 files changed, 191 insertions, 180 deletions
diff --git a/qmake/tools/qsettings.cpp b/qmake/tools/qsettings.cpp
index 35fc039..598e94b 100644
--- a/qmake/tools/qsettings.cpp
+++ b/qmake/tools/qsettings.cpp
@@ -1,3 +1,3 @@
/****************************************************************************
-** $Id$
+**
**
@@ -7,3 +7,3 @@
**
-** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2003 Trolltech AS. All rights reserved.
**
@@ -62,3 +62,5 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
#include <private/qsettings_p.h>
+#ifndef NO_ERRNO_H
#include <errno.h>
+#endif
@@ -103,3 +105,4 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
- A typical usage pattern for reading application startup:
+ A typical usage pattern for reading settings at application
+ startup:
\code
@@ -113,3 +116,4 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
- A typical usage pattern for application exit or 'save preferences':
+ A typical usage pattern for saving settings at application exit or
+ 'save preferences':
\code
@@ -123,4 +127,5 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
- QSettings can build a key prefix that is prepended to all keys. To
- build the key prefix, use beginGroup() and endGroup().
+ A key prefix can be prepended to all keys using beginGroup(). The
+ application of the prefix is stopped using endGroup(). For
+ example:
\code
@@ -156,4 +161,4 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
- Since settings for Windows are stored in the registry there are size
- limits as follows:
+ Since settings for Windows are stored in the registry there are
+ some size limitations as follows:
\list
@@ -167,5 +172,5 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
- If you wish to use a different search path call insertSearchPath()
- as often as necessary to add your preferred paths. Call
- removeSearchPath() to remove any unwanted paths.
+ \warning Creating multiple, simultaneous instances of QSettings writing
+ to a text file may lead to data loss! This is a known issue which will
+ be fixed in a future release of Qt.
@@ -173,12 +178,13 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
- Internal to the CFPreferences API it is not defined (for Mac OS 9
- support) where the settings will ultimitely be stored. However, at the
- time of this writing the settings will be stored (either on a global or
- user basis, preferring locally) into a plist file in
- $ROOT/System/Library/Preferences (in XML format). QSettings will create
- an appropriate plist file (com.<first group name>.plist) out of the
- full path to a key.
+ The location where settings are stored is not formally defined by
+ the CFPreferences API.
+
+ At the time of writing settings are stored (either on a global or
+ user basis, preferring locally) into a plist file in \c
+ $ROOT/System/Library/Preferences (in XML format). QSettings will
+ create an appropriate plist file (\c{com.<first group name>.plist})
+ out of the full path to a key.
- For further information on CFPreferences see also
- \link http://developer.apple.com/techpubs/macosx/CoreFoundation/PreferenceServices/preferenceservices_carbon.html
+ For further information on CFPreferences see
+ \link http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFPreferences/index.html
Apple's Specifications\endlink
@@ -191,6 +197,6 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
\list 1
- \i INSTALL/etc/settings
- \i /opt/MyCompany/share/etc
- \i /opt/MyCompany/share/MyApplication/etc
- \i $HOME/.qt
+ \i \c SYSCONF - the default value is \c INSTALL/etc/settings
+ \i \c /opt/MyCompany/share/etc
+ \i \c /opt/MyCompany/share/MyApplication/etc
+ \i \c $HOME/.qt
\endlist
@@ -219,4 +225,4 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
- For cross-platform applications you should ensure that the Windows
- size limitations are not exceeded.
+ For cross-platform applications you should ensure that the
+ \link #sizelimit Windows size limitations \endlink are not exceeded.
*/
@@ -312,41 +318,2 @@ static void closelock( HANDLE fd )
}
-#elif defined(Q_WS_WIN)
-#define Q_LOCKREAD 1
-#define Q_LOCKWRITE 2
-
-static HANDLE openlock( const QString &name, int /*type*/ )
-{
- if ( !QFile::exists( name ) )
- return 0;
-
- return 0;
-
- HANDLE fd = 0;
-
- QT_WA( {
- fd = CreateFileW( (TCHAR*)name.ucs2(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
- } , {
- fd = CreateFileA( name.local8Bit(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
- } );
-
- if ( !LockFile( fd, 0, 0, (DWORD)-1, (DWORD)-1 ) ) { // ### (DWORD)-1 ???
-#ifdef QT_CHECK_STATE
- qWarning( "QSettings: openlock failed!" );
-#endif
- }
- return fd;
-}
-
-static void closelock( HANDLE fd )
-{
- if ( !fd )
- return;
-
- if ( !UnlockFile( fd, 0, 0, (DWORD)-1, (DWORD)-1 ) ) { // ### (DWORD)-1 ???
-#ifdef QT_CHECK_STATE
- qWarning( "QSettings: closelock failed!");
-#endif
- }
- CloseHandle( fd );
-}
#endif
@@ -367,3 +334,5 @@ void QSettingsHeading::read(const QString &filename)
+#ifndef Q_WS_WIN
HANDLE lockfd = openlock( filename, Q_LOCKREAD );
+#endif
@@ -388,3 +357,5 @@ void QSettingsHeading::read(const QString &filename)
+#ifndef Q_WS_WIN
closelock( lockfd );
+#endif
}
@@ -406,3 +377,3 @@ void QSettingsHeading::parseLine(QTextStream &stream)
- gname = gname.remove(0, 1);
+ gname = gname.remove((uint)0, 1);
if (gname[(int)gname.length() - 1] == QChar(']'))
@@ -528,7 +499,3 @@ QSettingsPrivate::QSettingsPrivate( QSettings::Format format )
#else
-// for now
-#define QSETTINGS_DEFAULT_PATH_SUFFIX "/etc/settings"
-
- defPath = qInstallPath();
- defPath += QSETTINGS_DEFAULT_PATH_SUFFIX;
+ defPath = qInstallPathSysconf();
#endif
@@ -703,3 +670,3 @@ bool qt_verify_key( const QString &key )
{
- if ( key.isEmpty() || key[0] != '/' || key.contains( QRegExp("[=\\\\r\\\\n" ) ) )
+ if ( key.isEmpty() || key[0] != '/' || key.contains( QRegExp("[=\\r\\n]" ) ) )
return FALSE;
@@ -708,4 +675,5 @@ bool qt_verify_key( const QString &key )
-static inline QString groupKey( const QString &group, const QString &key )
+static QString groupKey( const QString &group, const QString &key )
{
+ QString grp_key;
if ( group.isEmpty() || ( group.length() == 1 && group[0] == '/' ) ) {
@@ -713,8 +681,11 @@ static inline QString groupKey( const QString &group, const QString &key )
if ( key.startsWith( "/" ) )
- return key;
- return "/" + key;
+ grp_key = key;
+ else
+ grp_key = "/" + key;
} else if ( group.endsWith( "/" ) || key.startsWith( "/" ) ) {
- return group + key;
+ grp_key = group + key;
+ } else {
+ grp_key = group + "/" + key;
}
- return group + "/" + key;
+ return grp_key;
}
@@ -723,3 +694,4 @@ static inline QString groupKey( const QString &group, const QString &key )
Inserts \a path into the settings search path. The semantics of \a
- path depends on the system \a s.
+ path depends on the system \a s. It is usually easier and better to
+ use setPath() instead of this function.
@@ -768,4 +740,5 @@ static inline QString groupKey( const QString &group, const QString &key )
\list 1
- \i INSTALL/etc - where \c INSTALL is the directory where Qt was installed.
- \i $HOME/.qt/ - where \c $HOME is the user's home directory.
+ \i \c SYSCONF - where \c SYSCONF is a directory specified when
+ configuring Qt; by default it is INSTALL/etc/settings.
+ \i \c $HOME/.qt/ - where \c $HOME is the user's home directory.
\endlist
@@ -782,3 +755,3 @@ static inline QString groupKey( const QString &group, const QString &key )
\list 1
- \i INSTALL/etc
+ \i SYSCONF
\i /opt/MyCompany/share/etc
@@ -793,2 +766,5 @@ static inline QString groupKey( const QString &group, const QString &key )
+ Note that paths in the file system are not created by this
+ function, so they must already exist to be useful.
+
Settings under Unix are stored in files whose names are based on the
@@ -817,3 +793,3 @@ void QSettings::insertSearchPath( System s, const QString &path)
#endif
-#if !defined(Q_WS_WIN)
+#if !defined(Q_OS_MAC)
if ( s == Mac )
@@ -966,3 +942,3 @@ bool QSettings::sync()
QSettingsHeading::Iterator hdit = hd.begin();
- QFile file;
+ QString filename;
@@ -974,2 +950,7 @@ bool QSettings::sync()
QFileInfo di(*pit);
+ if ( !di.exists() ) {
+ QDir dir;
+ dir.mkdir( *pit );
+ }
+
QFileInfo fi((*pit++) + "/" + filebase + "rc");
@@ -977,4 +958,10 @@ bool QSettings::sync()
if ((fi.exists() && fi.isFile() && fi.isWritable()) ||
- (! fi.exists() && di.isDir() && di.isWritable())) {
- file.setName(fi.filePath());
+ (! fi.exists() && di.isDir()
+#ifndef Q_WS_WIN
+ && di.isWritable()
+#else
+ && ((qWinVersion()&Qt::WV_NT_based) > Qt::WV_2000 || di.isWritable())
+#endif
+ )) {
+ filename = fi.filePath();
break;
@@ -985,3 +972,3 @@ bool QSettings::sync()
- if ( file.name().isEmpty() ) {
+ if ( filename.isEmpty() ) {
@@ -995,4 +982,7 @@ bool QSettings::sync()
- HANDLE lockfd = openlock( file.name(), Q_LOCKWRITE );
+#ifndef Q_WS_WIN
+ HANDLE lockfd = openlock( filename, Q_LOCKWRITE );
+#endif
+ QFile file( filename + ".tmp" );
if (! file.open(IO_WriteOnly)) {
@@ -1049,3 +1039,22 @@ bool QSettings::sync()
+ if ( success ) {
+ QDir dir( QFileInfo( file ).dir( TRUE ) );
+ if ( dir.exists( filename ) && !dir.remove( filename ) ||
+ !dir.rename( file.name(), filename, TRUE ) ) {
+
+#ifdef QT_CHECK_STATE
+ qWarning( "QSettings::sync: error writing file '%s'",
+ QFile::encodeName( filename ).data() );
+#endif // QT_CHECK_STATE
+
+ success = FALSE;
+ }
+ }
+
+ // remove temporary file
+ file.remove();
+
+#ifndef Q_WS_WIN
closelock( lockfd );
+#endif
}
@@ -1074,5 +1083,6 @@ bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok )
{
- if ( !qt_verify_key( key ) ) {
+ QString grp_key( groupKey( group(), key ) );
+ if ( !qt_verify_key( grp_key ) ) {
#if defined(QT_CHECK_STATE)
- qWarning( "QSettings::readBoolEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
+ qWarning( "QSettings::readBoolEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() );
#endif
@@ -1086,3 +1096,3 @@ bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok )
if ( d->sysd )
- return d->sysReadBoolEntry( groupKey( group(), key ), def, ok );
+ return d->sysReadBoolEntry( grp_key, def, ok );
#endif
@@ -1125,5 +1135,6 @@ double QSettings::readDoubleEntry(const QString &key, double def, bool *ok )
{
- if ( !qt_verify_key( key ) ) {
+ QString grp_key( groupKey( group(), key ) );
+ if ( !qt_verify_key( grp_key ) ) {
#if defined(QT_CHECK_STATE)
- qWarning( "QSettings::readDoubleEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
+ qWarning( "QSettings::readDoubleEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() );
#endif
@@ -1137,3 +1148,3 @@ double QSettings::readDoubleEntry(const QString &key, double def, bool *ok )
if ( d->sysd )
- return d->sysReadDoubleEntry( groupKey( group(), key ), def, ok );
+ return d->sysReadDoubleEntry( grp_key, def, ok );
#endif
@@ -1170,5 +1181,6 @@ int QSettings::readNumEntry(const QString &key, int def, bool *ok )
{
- if ( !qt_verify_key( key ) ) {
+ QString grp_key( groupKey( group(), key ) );
+ if ( !qt_verify_key( grp_key ) ) {
#if defined(QT_CHECK_STATE)
- qWarning( "QSettings::readNumEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
+ qWarning( "QSettings::readNumEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() );
#endif
@@ -1181,3 +1193,3 @@ int QSettings::readNumEntry(const QString &key, int def, bool *ok )
if ( d->sysd )
- return d->sysReadNumEntry( groupKey( group(), key ), def, ok );
+ return d->sysReadNumEntry( grp_key, def, ok );
#endif
@@ -1214,5 +1226,6 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok )
{
- if ( !qt_verify_key( key ) ) {
+ QString grp_key( groupKey( group(), key ) );
+ if ( !qt_verify_key( grp_key ) ) {
#if defined(QT_CHECK_STATE)
- qWarning( "QSettings::readEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
+ qWarning( "QSettings::readEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() );
#endif
@@ -1224,7 +1237,5 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok )
- QString theKey = groupKey( group(), key );
-
#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
- return d->sysReadEntry( theKey, def, ok );
+ return d->sysReadEntry( grp_key, def, ok );
#endif
@@ -1236,5 +1247,5 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok )
- if (theKey[0] == '/') {
+ if (grp_key[0] == '/') {
// parse our key
- QStringList list(QStringList::split('/', theKey));
+ QStringList list(QStringList::split('/', grp_key));
@@ -1242,3 +1253,3 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok )
#ifdef QT_CHECK_STATE
- qWarning("QSettings::readEntry: invalid key '%s'", theKey.latin1());
+ qWarning("QSettings::readEntry: invalid key '%s'", grp_key.latin1());
#endif // QT_CHECK_STATE
@@ -1264,4 +1275,5 @@ QString QSettings::readEntry(const QString &key, const QString &def, bool *ok )
}
- } else
- realkey = theKey;
+ } else {
+ realkey = grp_key;
+ }
@@ -1292,5 +1304,6 @@ bool QSettings::writeEntry(const QString &key, bool value)
{
- if ( !qt_verify_key( key ) ) {
+ QString grp_key( groupKey( group(), key ) );
+ if ( !qt_verify_key( grp_key ) ) {
#if defined(QT_CHECK_STATE)
- qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
+ qWarning( "QSettings::writeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() );
#endif
@@ -1301,3 +1314,3 @@ bool QSettings::writeEntry(const QString &key, bool value)
if ( d->sysd )
- return d->sysWriteEntry( groupKey( group(), key ), value );
+ return d->sysWriteEntry( grp_key, value );
#endif
@@ -1322,5 +1335,6 @@ bool QSettings::writeEntry(const QString &key, double value)
{
- if ( !qt_verify_key( key ) ) {
+ QString grp_key( groupKey( group(), key ) );
+ if ( !qt_verify_key( grp_key ) ) {
#if defined(QT_CHECK_STATE)
- qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
+ qWarning( "QSettings::writeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() );
#endif
@@ -1331,3 +1345,3 @@ bool QSettings::writeEntry(const QString &key, double value)
if ( d->sysd )
- return d->sysWriteEntry( groupKey( group(), key ), value );
+ return d->sysWriteEntry( grp_key, value );
#endif
@@ -1351,5 +1365,6 @@ bool QSettings::writeEntry(const QString &key, int value)
{
- if ( !qt_verify_key( key ) ) {
+ QString grp_key( groupKey( group(), key ) );
+ if ( !qt_verify_key( grp_key ) ) {
#if defined(QT_CHECK_STATE)
- qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
+ qWarning( "QSettings::writeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() );
#endif
@@ -1360,3 +1375,3 @@ bool QSettings::writeEntry(const QString &key, int value)
if ( d->sysd )
- return d->sysWriteEntry( groupKey( group(), key ), value );
+ return d->sysWriteEntry( grp_key, value );
#endif
@@ -1385,9 +1400,2 @@ bool QSettings::writeEntry(const QString &key, const char *value)
{
- if ( !qt_verify_key( key ) ) {
-#if defined(QT_CHECK_STATE)
- qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
-#endif
- return FALSE;
- }
-
return writeEntry(key, QString(value));
@@ -1410,5 +1418,6 @@ bool QSettings::writeEntry(const QString &key, const QString &value)
{
- if ( !qt_verify_key( key ) ) {
+ QString grp_key( groupKey( group(), key ) );
+ if ( !qt_verify_key( grp_key ) ) {
#if defined(QT_CHECK_STATE)
- qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
+ qWarning( "QSettings::writeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() );
#endif
@@ -1417,7 +1426,5 @@ bool QSettings::writeEntry(const QString &key, const QString &value)
- QString theKey = groupKey( group(), key );
-
#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
- return d->sysWriteEntry( theKey, value );
+ return d->sysWriteEntry( grp_key, value );
#endif
@@ -1427,5 +1434,5 @@ bool QSettings::writeEntry(const QString &key, const QString &value)
- if (theKey[0] == '/') {
+ if (grp_key[0] == '/') {
// parse our key
- QStringList list(QStringList::split('/', theKey));
+ QStringList list(QStringList::split('/', grp_key));
@@ -1433,3 +1440,3 @@ bool QSettings::writeEntry(const QString &key, const QString &value)
#ifdef QT_CHECK_STATE
- qWarning("QSettings::writeEntry: invalid key '%s'", theKey.latin1());
+ qWarning("QSettings::writeEntry: invalid key '%s'", grp_key.latin1());
#endif // QT_CHECK_STATE
@@ -1454,4 +1461,5 @@ bool QSettings::writeEntry(const QString &key, const QString &value)
}
- } else
- realkey = theKey;
+ } else {
+ realkey = grp_key;
+ }
@@ -1471,5 +1479,6 @@ bool QSettings::removeEntry(const QString &key)
{
- if ( !qt_verify_key( key ) ) {
+ QString grp_key( groupKey( group(), key ) );
+ if ( !qt_verify_key( grp_key ) ) {
#if defined(QT_CHECK_STATE)
- qWarning( "QSettings::removeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
+ qWarning( "QSettings::removeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() );
#endif
@@ -1478,7 +1487,5 @@ bool QSettings::removeEntry(const QString &key)
- QString theKey = groupKey( group(), key );
-
#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
- return d->sysRemoveEntry( theKey );
+ return d->sysRemoveEntry( grp_key );
#endif
@@ -1486,6 +1493,5 @@ bool QSettings::removeEntry(const QString &key)
QString realkey;
-
- if (theKey[0] == '/') {
+ if (grp_key[0] == '/') {
// parse our key
- QStringList list(QStringList::split('/', theKey));
+ QStringList list(QStringList::split('/', grp_key));
@@ -1493,3 +1499,3 @@ bool QSettings::removeEntry(const QString &key)
#ifdef QT_CHECK_STATE
- qWarning("QSettings::removeEntry: invalid key '%s'", theKey.latin1());
+ qWarning("QSettings::removeEntry: invalid key '%s'", grp_key.latin1());
#endif // QT_CHECK_STATE
@@ -1514,4 +1520,5 @@ bool QSettings::removeEntry(const QString &key)
}
- } else
- realkey = theKey;
+ } else {
+ realkey = grp_key;
+ }
@@ -1550,5 +1557,6 @@ QStringList QSettings::entryList(const QString &key) const
{
- if ( !qt_verify_key( key ) ) {
+ QString grp_key( groupKey( group(), key ) );
+ if ( !qt_verify_key( grp_key ) ) {
#if defined(QT_CHECK_STATE)
- qWarning( "QSettings::entryList: Invalid key: %s", key.isNull() ? "(null)" : key.latin1() );
+ qWarning( "QSettings::entryList: Invalid key: %s", grp_key.isNull() ? "(null)" : grp_key.latin1() );
#endif
@@ -1557,7 +1565,5 @@ QStringList QSettings::entryList(const QString &key) const
- QString theKey = groupKey( group(), key );
-
#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
- return d->sysEntryList( theKey );
+ return d->sysEntryList( grp_key );
#endif
@@ -1565,5 +1571,5 @@ QStringList QSettings::entryList(const QString &key) const
QString realkey;
- if (theKey[0] == '/') {
+ if (grp_key[0] == '/') {
// parse our key
- QStringList list(QStringList::split('/', theKey));
+ QStringList list(QStringList::split('/', grp_key));
@@ -1571,3 +1577,3 @@ QStringList QSettings::entryList(const QString &key) const
#ifdef QT_CHECK_STATE
- qWarning("QSettings::listEntries: invalid key '%s'", theKey.latin1());
+ qWarning("QSettings::listEntries: invalid key '%s'", grp_key.latin1());
#endif // QT_CHECK_STATE
@@ -1592,3 +1598,3 @@ QStringList QSettings::entryList(const QString &key) const
} else
- realkey = theKey;
+ realkey = grp_key;
@@ -1647,5 +1653,6 @@ QStringList QSettings::subkeyList(const QString &key) const
{
- if ( !qt_verify_key( key ) ) {
+ QString grp_key( groupKey( group(), key ) );
+ if ( !qt_verify_key( grp_key ) ) {
#if defined(QT_CHECK_STATE)
- qWarning( "QSettings::subkeyList: Invalid key: %s", key.isNull() ? "(null)" : key.latin1() );
+ qWarning( "QSettings::subkeyList: Invalid key: %s", grp_key.isNull() ? "(null)" : grp_key.latin1() );
#endif
@@ -1654,7 +1661,5 @@ QStringList QSettings::subkeyList(const QString &key) const
- QString theKey = groupKey( group(), key );
-
#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
if ( d->sysd )
- return d->sysSubkeyList( theKey );
+ return d->sysSubkeyList( grp_key );
#endif
@@ -1663,5 +1668,5 @@ QStringList QSettings::subkeyList(const QString &key) const
int subkeycount = 2;
- if (theKey[0] == '/') {
+ if (grp_key[0] == '/') {
// parse our key
- QStringList list(QStringList::split('/', theKey));
+ QStringList list(QStringList::split('/', grp_key));
@@ -1669,3 +1674,3 @@ QStringList QSettings::subkeyList(const QString &key) const
#ifdef QT_CHECK_STATE
- qWarning("QSettings::subkeyList: invalid key '%s'", theKey.latin1());
+ qWarning("QSettings::subkeyList: invalid key '%s'", grp_key.latin1());
#endif // QT_CHECK_STATE
@@ -1693,3 +1698,3 @@ QStringList QSettings::subkeyList(const QString &key) const
} else
- realkey = theKey;
+ realkey = grp_key;
@@ -1739,7 +1744,8 @@ QStringList QSettings::subkeyList(const QString &key) const
*/
-QDateTime QSettings::lastModficationTime(const QString &key)
+QDateTime QSettings::lastModificationTime( const QString &key )
{
- if ( !qt_verify_key( key ) ) {
+ QString grp_key( groupKey( group(), key ) );
+ if ( !qt_verify_key( grp_key ) ) {
#if defined(QT_CHECK_STATE)
- qWarning( "QSettings::lastModficationTime: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
+ qWarning( "QSettings::lastModificationTime: Invalid key '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() );
#endif
@@ -1748,4 +1754,2 @@ QDateTime QSettings::lastModficationTime(const QString &key)
- QString theKey = groupKey( group(), key );
-
#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
@@ -1755,5 +1759,5 @@ QDateTime QSettings::lastModficationTime(const QString &key)
- if (theKey[0] == '/') {
+ if (grp_key[0] == '/') {
// parse our key
- QStringList list(QStringList::split('/', theKey));
+ QStringList list(QStringList::split('/', grp_key));
@@ -1761,3 +1765,3 @@ QDateTime QSettings::lastModficationTime(const QString &key)
#ifdef QT_CHECK_STATE
- qWarning("QSettings::lastModficationTime: invalid key '%s'", theKey.latin1());
+ qWarning("QSettings::lastModificationTime: Invalid key '%s'", grp_key.latin1());
#endif // QT_CHECK_STATE
@@ -1782,2 +1786,3 @@ QDateTime QSettings::lastModficationTime(const QString &key)
\overload
+ \obsolete
@@ -1798,2 +1803,3 @@ QDateTime QSettings::lastModficationTime(const QString &key)
+
If an error occurs the settings are left unchanged and FALSE is
@@ -1801,3 +1807,3 @@ QDateTime QSettings::lastModficationTime(const QString &key)
- \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry()
+ \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry(), QStringList::join()
*/
@@ -1841,2 +1847,3 @@ bool QSettings::writeEntry(const QString &key, const QStringList &value)
\overload QStringList QSettings::readListEntry(const QString &key, const QChar &separator, bool *ok ) const
+ \obsolete
@@ -1844,4 +1851,4 @@ bool QSettings::writeEntry(const QString &key, const QStringList &value)
is used to create a QStringList by calling QStringList::split(\a
- separator, entry). If \a ok is not 0: \a *ok is set to TRUE if the
- key was read, otherwise \a *ok is set to FALSE.
+ separator, entry). If \a ok is not 0: \a *ok is set to TRUE
+ if the key was read, otherwise \a *ok is set to FALSE.
@@ -1853,3 +1860,2 @@ bool QSettings::writeEntry(const QString &key, const QStringList &value)
-
Note that if you want to iterate over the list, you should iterate
@@ -1951,4 +1957,3 @@ void qt_setSettingsBasePath(const QString &); //qsettings_mac.cpp
- Not all information is relevant on all systems (e.g. scoping is
- currently used only if QSettings accesses the Windows registry).
+ Not all information is relevant on all systems.
*/
@@ -1982,9 +1987,15 @@ void QSettings::setPath( const QString &domain, const QString &product, Scope sc
#elif !defined(QWS) && defined(Q_OS_MAC)
- QString topLevelDomain = domain.right( domain.length() - lastDot - 1 ) + ".";
- if ( !topLevelDomain.isEmpty() )
- qt_setSettingsBasePath( topLevelDomain );
- actualSearchPath = "/" + domain.left( lastDot ) + product;
+ if(lastDot != -1) {
+ QString topLevelDomain = domain.right( domain.length() - lastDot - 1 ) + ".";
+ if ( !topLevelDomain.isEmpty() )
+ qt_setSettingsBasePath( topLevelDomain );
+ }
+ actualSearchPath = "/" + domain.left( lastDot ) + "." + product;
insertSearchPath( Mac, actualSearchPath );
#else
- actualSearchPath = "/" + domain.mid( 0, lastDot ) + "/" + product;
+ if (scope == User)
+ actualSearchPath = QDir::homeDirPath() + "/.";
+ else
+ actualSearchPath = QString(qInstallPathSysconf()) + "/";
+ actualSearchPath += domain.mid( 0, lastDot ) + "/" + product;
insertSearchPath( Unix, actualSearchPath );