Destroy DebugConsole on hide of QWindow

Summary:
The quit button in the DebugConsole is connected to deleteLater on the
DebugConsole. This is to clean up resources like the input event filter
which is rather expensive to have running.

When closed through the window decoration the DebugConsole window only
got hidden but not destroyed. Resulting in the input filter to continue
processing.

This change ensures that the DebugConsole gets properly destroyed once
the window gets hidden.

BUG: 369858
FIXED-IN: 5.8.1

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2931
This commit is contained in:
Martin Gräßlin 2016-10-04 14:06:01 +02:00
parent 13991f85ea
commit fd6e4bb023
3 changed files with 19 additions and 2 deletions

View file

@ -522,9 +522,7 @@ void DebugConsoleTest::testClosingDebugConsole()
QCOMPARE(c->internalWindow(), console->windowHandle());
QVERIFY(c->isDecorated());
c->closeWindow();
QEXPECT_FAIL("", "BUG 369858", Continue);
QVERIFY(destroyedSpy.wait());
QCOMPARE(console->windowHandle()->isVisible(), false);
}
}

View file

@ -536,6 +536,22 @@ void DebugConsole::initGLTab()
m_ui->openGLExtensionsLabel->setText(extensionsString(openGLExtensions()));
}
void DebugConsole::showEvent(QShowEvent *event)
{
QWidget::showEvent(event);
// delay the connection to the show event as in ctor the windowHandle returns null
connect(windowHandle(), &QWindow::visibleChanged, this,
[this] (bool visible) {
if (visible) {
// ignore
return;
}
deleteLater();
}
);
}
DebugConsoleDelegate::DebugConsoleDelegate(QObject *parent)
: QStyledItemDelegate(parent)
{

View file

@ -101,6 +101,9 @@ public:
DebugConsole();
virtual ~DebugConsole();
protected:
void showEvent(QShowEvent *event) override;
private:
void initGLTab();