void QSettingsPrivate::notify()
{
- Q_Q(QSettings);
QMutexLocker locker(qSettingsMutex());
shouldwrite = true;
for (int i = 0; i < qGlobalSettings()->size(); i++) {
QSettings *setting = qGlobalSettings()->at(i);
- if (setting != q && setting->fileName() == q->fileName()) {
+ if (setting->d_func() != this && setting->fileName() == filename) {
setting->d_func()->map = map;
setting->d_func()->shouldwrite = false;
}
\sa QCoreApplication::setApplicationName()
*/
-QSettings::QSettings(QObject *parent)
- : QObject(*new QSettingsPrivate(QSettings::NativeFormat), parent)
+QSettings::QSettings()
+ : d_ptr(new QSettingsPrivate(QSettings::NativeFormat))
{
QMutexLocker locker(qSettingsMutex());
qGlobalSettings()->append(this);
}
/*!
- Constructs a QSettings object for accessing settings with parent
- \a parent.
+ Constructs a QSettings object for accessing settings.
If \a format is QSettings::NativeFormat, the native JSON API is used
for storing settings. If \a format is QSettings::IniFormat, the INI
format is used.
*/
-QSettings::QSettings(Format format, QObject *parent)
- : QObject(*new QSettingsPrivate(format), parent)
+QSettings::QSettings(Format format)
+ : d_ptr(new QSettingsPrivate(format))
{
QMutexLocker locker(qSettingsMutex());
qGlobalSettings()->append(this);
}
/*!
- Constructs a QSettings object for accessing the settings
- stored in the file called \a fileName, with parent \a parent. If
- the file doesn't already exist, it is created.
+ Constructs a QSettings object for accessing the settings stored in the
+ file called \a fileName. If the file doesn't already exist, it is created.
The meaning of \a fileName depends on the format. If \a format is
QSettings::NativeFormat, the filename will end with end with .json
\sa fileName()
*/
-QSettings::QSettings(const QString &fileName, Format format, QObject *parent)
- : QObject(*new QSettingsPrivate(fileName, format), parent)
+QSettings::QSettings(const QString &fileName, Format format)
+ : d_ptr(new QSettingsPrivate(fileName, format))
{
QMutexLocker locker(qSettingsMutex());
qGlobalSettings()->append(this);
QMutexLocker locker(qSettingsMutex());
const int index = qGlobalSettings()->indexOf(this);
qGlobalSettings()->remove(index);
+ delete d_ptr;
}
/*!
Typedef for QMap<QString, QVariant>.
*/
-#include "moc_qsettings.h"
-
QT_END_NAMESPACE
#endif // QT_NO_SETTINGS
class QSettingsPrivate;
-class Q_CORE_EXPORT QSettings : public QObject
+class Q_CORE_EXPORT QSettings
{
- Q_OBJECT
Q_DECLARE_PRIVATE(QSettings)
public:
typedef QMap<QString, QVariant> SettingsMap;
- explicit QSettings(QObject *parent = nullptr);
- QSettings(Format format, QObject *parent = nullptr);
- QSettings(const QString &fileName, Format format = NativeFormat, QObject *parent = nullptr);
+ QSettings();
+ QSettings(Format format);
+ QSettings(const QString &fileName, Format format = NativeFormat);
~QSettings();
void clear();
private:
Q_DISABLE_COPY(QSettings)
+ QSettingsPrivate *d_ptr;
};
QT_END_NAMESPACE