backends/x11: explicitly free the outputs
...before releasing the connection! this was randomly causing crashes because of use-after-disconnect problems. since we would tear down the connection in ~X11WindowedBackend but outputs wouldn't get cleaned up until QObject children cleanup of the X11WindowedBackend object (or more precisely the OutputBase). this would then result in ~X11WindowedOutput accessing a backend connection that had already been closed to help debug this type of problem moving forward let's also reset the connection to nullptr during destruction. it's kinda pointless but it makes it easier to spot use-after-disconnect BUG: 466183
This commit is contained in:
parent
08e392f368
commit
4fcc545628
2 changed files with 14 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
||||
SPDX-FileCopyrightText: 2023 Harald Sitter <sitter@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
@ -160,6 +161,7 @@ X11WindowedBackend::X11WindowedBackend(const X11WindowedBackendOptions &options)
|
|||
|
||||
X11WindowedBackend::~X11WindowedBackend()
|
||||
{
|
||||
destroyOutputs();
|
||||
m_pointerDevice.reset();
|
||||
m_keyboardDevice.reset();
|
||||
m_touchDevice.reset();
|
||||
|
@ -172,6 +174,7 @@ X11WindowedBackend::~X11WindowedBackend()
|
|||
xcb_key_symbols_free(m_keySymbols);
|
||||
}
|
||||
xcb_disconnect(m_connection);
|
||||
m_connection = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -691,4 +694,14 @@ Outputs X11WindowedBackend::outputs() const
|
|||
return m_outputs;
|
||||
}
|
||||
|
||||
void X11WindowedBackend::destroyOutputs()
|
||||
{
|
||||
while (!m_outputs.isEmpty()) {
|
||||
auto output = m_outputs.takeLast();
|
||||
output->updateEnabled(false);
|
||||
Q_EMIT outputRemoved(output);
|
||||
delete output;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace KWin
|
||||
|
|
|
@ -129,6 +129,7 @@ private:
|
|||
void updateSize(xcb_configure_notify_event_t *event);
|
||||
void initXInput();
|
||||
X11WindowedOutput *findOutput(xcb_window_t window) const;
|
||||
void destroyOutputs();
|
||||
|
||||
X11WindowedBackendOptions m_options;
|
||||
xcb_connection_t *m_connection = nullptr;
|
||||
|
|
Loading…
Reference in a new issue