Commit 375b7e52 authored by Martin Flöser's avatar Martin Flöser

[idletime] Tear-down Wayland objects before app quits

The created Wayland objects were destroyed when the Poller got
destroyed. In the case of KIdleTime the Poller gets destroyed on library
unload which happens after the QGuiApplication was destroyed. This means
the Wayland connection used to create the objects does not exist any
more.

With latest Wayland library trying to destroy objects after the Wayland
connection got destroyed results in a crash as we can see currently on
build.kde.org.

This change implements custom Wayland cleanup code in
Poller::unloadPoller. To ensure that unloadPoller gets invoked a
connection on destroy of platformNativeInterface is set up which happens
before the Wayland connection is getting destroyed.

This change hopefully fixes the crash on build.kde.org. It might be that
there is another object not yet destroyed, we'll see.
parent cbc15382
......@@ -24,6 +24,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <KWayland/Client/registry.h>
#include <KWayland/Client/seat.h>
#include <QGuiApplication>
#include <QDebug>
#include <QLoggingCategory>
#include <QMutex>
......@@ -52,6 +53,9 @@ bool Poller::initWayland()
if (!connection) {
return false;
}
// need to be able to cleanup prior to the Wayland connection being destroyed
// otherwise we get a crash in libwayland
connect(reinterpret_cast<QObject*>(qApp->platformNativeInterface()), &QObject::destroyed, this, &Poller::unloadPoller);
m_registry = new Registry(this);
m_registry->create(connection);
connect(m_registry, &Registry::seatAnnounced, this,
......@@ -116,7 +120,19 @@ bool Poller::setUpPoller()
void Poller::unloadPoller()
{
qDeleteAll(m_timeouts);
m_timeouts.clear();
delete m_catchResumeTimeout;
m_catchResumeTimeout = nullptr;
delete m_registry;
m_registry = nullptr;
delete m_seat.seat;
m_seat.seat = nullptr;
delete m_idle.idle;
m_idle.idle = nullptr;
}
void Poller::addTimeout(int nextTimeout)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment