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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-07-30 20:59:07 +02:00 committed by Dirk Hohndel
parent 4bdd811f06
commit 7fe76a5dbd
5 changed files with 5 additions and 39 deletions

View file

@ -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();
}