clang-tidy: Avoid potential memory leak in QtUi
[quassel.git] / src / qtui / qtui.cpp
index a37bc40..d335d07 100644 (file)
 #include "types.h"
 #include "util.h"
 
-QtUi *QtUi::_instance = nullptr;
 MainWin *QtUi::_mainWin = nullptr;
 QList<AbstractNotificationBackend *> QtUi::_notificationBackends;
 QList<AbstractNotificationBackend::Notification> QtUi::_notifications;
 
+namespace {
+
+QtUi *_instance{nullptr};
+
+}
+
+
+QtUi *QtUi::instance()
+{
+    if (!_instance) {
+        _instance = new QtUi();
+    }
+    return _instance;
+}
+
+
 QtUi::QtUi()
     : GraphicalUi()
     , _systemIconTheme{QIcon::themeName()}
 {
-    if (_instance != nullptr) {
-        qWarning() << "QtUi has been instantiated again!";
-        return;
-    }
-    _instance = this;
-
     if (Quassel::isOptionSet("icontheme")) {
         _systemIconTheme = Quassel::optionValue("icontheme");
         QIcon::setThemeName(_systemIconTheme);
@@ -345,7 +354,7 @@ void QtUi::refreshIconTheme()
         }
     }
 
-    if (_systemIconTheme.isEmpty() || _systemIconTheme == fallbackTheme || s.value("Icons/OverrideSystemTheme", false).toBool()) {
+    if (_systemIconTheme.isEmpty() || _systemIconTheme == fallbackTheme || s.value("Icons/OverrideSystemTheme", true).toBool()) {
         // We have a valid fallback theme and want to override the system theme (if it's even defined), so we're basically done
         QIcon::setThemeName(fallbackTheme);
         emit iconThemeRefreshed();