From a189118e82c7846d9e1376dc18738a0b0b1d1264 Mon Sep 17 00:00:00 2001 From: Benni Date: Sun, 4 Aug 2024 23:36:15 +0200 Subject: [PATCH] Do not delete the static Settings instance in its own destructor --- src/settings.cpp | 9 ++------- src/settings.h | 2 -- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/settings.cpp b/src/settings.cpp index 5396aae..c46bdec 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -31,14 +31,10 @@ #include -Settings* Settings::m_instance = nullptr; - Settings* Settings::instance() { - if( !m_instance ) - m_instance = new Settings(); - - return m_instance; + static auto settings = Settings(); + return &settings; } Settings::Settings( QObject *parent ) @@ -55,7 +51,6 @@ Settings::Settings( QObject *parent ) Settings::~Settings() { delete m_mutex; - delete m_instance; } KCardCache* Settings::cardCache() diff --git a/src/settings.h b/src/settings.h index d1c8021..ea4b0ef 100644 --- a/src/settings.h +++ b/src/settings.h @@ -133,8 +133,6 @@ class Settings : public QObject Settings( QObject *parent = 0 ); ~Settings(); - static Settings* m_instance; - KSharedConfig::Ptr m_config; QMutex* m_mutex;