From 7fe76a5dbdef4a833122e0311191dd51896575f4 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 30 Jul 2018 20:59:07 +0200 Subject: Cleanup: Make WindowsTitleUpdate a global object WindowsTitleUpdate is such a trivial object (a QObject with a single signal and no own state), that it's not really understandable why it would need all that "singleton" boiler-plate. Just make it a default constructed/destructed global object. Signed-off-by: Berthold Stoeger --- core/windowtitleupdate.cpp | 28 ++-------------------------- core/windowtitleupdate.h | 9 ++------- 2 files changed, 4 insertions(+), 33 deletions(-) (limited to 'core') diff --git a/core/windowtitleupdate.cpp b/core/windowtitleupdate.cpp index 810acd4dc..a0cc277b3 100644 --- a/core/windowtitleupdate.cpp +++ b/core/windowtitleupdate.cpp @@ -1,33 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 #include "windowtitleupdate.h" -WindowTitleUpdate *WindowTitleUpdate::m_instance = NULL; - -WindowTitleUpdate::WindowTitleUpdate(QObject *parent) : QObject(parent) -{ - Q_ASSERT_X(m_instance == NULL, "WindowTitleUpdate", "WindowTitleUpdate recreated!"); - - m_instance = this; -} - -WindowTitleUpdate *WindowTitleUpdate::instance() -{ - return m_instance; -} - -WindowTitleUpdate::~WindowTitleUpdate() -{ - m_instance = NULL; -} - -void WindowTitleUpdate::emitSignal() -{ - emit updateTitle(); -} +WindowTitleUpdate windowTitleUpdate; extern "C" void updateWindowTitle() { - WindowTitleUpdate *wt = WindowTitleUpdate::instance(); - if (wt) - wt->emitSignal(); + emit windowTitleUpdate.updateTitle(); } diff --git a/core/windowtitleupdate.h b/core/windowtitleupdate.h index dcda821e9..f08467789 100644 --- a/core/windowtitleupdate.h +++ b/core/windowtitleupdate.h @@ -7,15 +7,10 @@ class WindowTitleUpdate : public QObject { Q_OBJECT -public: - explicit WindowTitleUpdate(QObject *parent = 0); - ~WindowTitleUpdate(); - static WindowTitleUpdate *instance(); - void emitSignal(); signals: void updateTitle(); -private: - static WindowTitleUpdate *m_instance; }; +extern WindowTitleUpdate windowTitleUpdate; + #endif // WINDOWTITLEUPDATE_H -- cgit v1.2.3-70-g09d2