Use a reference for the singleton

This is a bit nicer to work with than a pointer and doesn't require a
heap allocation.
This commit is contained in:
Carl Schwan 2024-01-17 01:02:51 +01:00
parent 6fc90ca25e
commit b070f6e3f7
No known key found for this signature in database
GPG key ID: 02325448204E452A
3 changed files with 4 additions and 4 deletions

View file

@ -39,7 +39,7 @@ int main(int argc, char *argv[])
// apply configuration
if (parser->isSet(QStringLiteral("apply-settings"))) {
Settings::self()->applyConfiguration();
Settings::self().applyConfiguration();
} else {
parser->showHelp();
}

View file

@ -27,9 +27,9 @@ Settings::Settings(QObject *parent)
{
}
Settings *Settings::self()
Settings &Settings::self()
{
static Settings *settings = new Settings;
static Settings settings;
return settings;
}

View file

@ -15,7 +15,7 @@ class Settings : public QObject
public:
Settings(QObject *parent = nullptr);
static Settings *self();
static Settings &self();
// apply the configuration
void applyConfiguration();