Ensure internal Wayland connection is properly setup before creating LockScreen integration

With the new Wayland only mode we start too fast and it can happen that
the initWithWorkspace is called before the client connection is fully
setup. This would result in a crash in the idletime plugin once it tries
to create a seat.

To prevent this problem the code is split out into a dedicated method
and only invoked if all interfaces have been announced on the internal
connection.
icc-effect-5.14.5
Martin Flöser 2017-09-30 16:33:45 +02:00
parent 3ce9a4a179
commit 4c334098f3
2 changed files with 37 additions and 19 deletions

View File

@ -337,26 +337,37 @@ void WaylandServer::initWorkspace()
}
if (hasScreenLockerIntegration()) {
ScreenLocker::KSldApp::self();
ScreenLocker::KSldApp::self()->setWaylandDisplay(m_display);
ScreenLocker::KSldApp::self()->setGreeterEnvironment(kwinApp()->processStartupEnvironment());
ScreenLocker::KSldApp::self()->initialize();
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::greeterClientConnectionChanged, this,
[this] () {
m_screenLockerClientConnection = ScreenLocker::KSldApp::self()->greeterClientConnection();
}
);
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::unlocked, this,
[this] () {
m_screenLockerClientConnection = nullptr;
}
);
if (m_initFlags.testFlag(InitalizationFlag::LockScreen)) {
ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate);
if (m_internalConnection.interfacesAnnounced) {
initScreenLocker();
} else {
connect(m_internalConnection.registry, &KWayland::Client::Registry::interfacesAnnounced, this, &WaylandServer::initScreenLocker);
}
} else {
emit initialized();
}
}
void WaylandServer::initScreenLocker()
{
ScreenLocker::KSldApp::self();
ScreenLocker::KSldApp::self()->setWaylandDisplay(m_display);
ScreenLocker::KSldApp::self()->setGreeterEnvironment(kwinApp()->processStartupEnvironment());
ScreenLocker::KSldApp::self()->initialize();
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::greeterClientConnectionChanged, this,
[this] () {
m_screenLockerClientConnection = ScreenLocker::KSldApp::self()->greeterClientConnection();
}
);
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::unlocked, this,
[this] () {
m_screenLockerClientConnection = nullptr;
}
);
if (m_initFlags.testFlag(InitalizationFlag::LockScreen)) {
ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate);
}
emit initialized();
}
@ -528,6 +539,11 @@ void WaylandServer::createInternalConnection()
m_internalConnection.shm = m_internalConnection.registry->createShmPool(name, version, this);
}
);
connect(registry, &Registry::interfacesAnnounced, this,
[this] {
m_internalConnection.interfacesAnnounced = true;
}
);
registry->setup();
}
);

View File

@ -200,6 +200,7 @@ private:
void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config);
template <class T>
void createSurface(T *surface);
void initScreenLocker();
KWayland::Server::Display *m_display = nullptr;
KWayland::Server::CompositorInterface *m_compositor = nullptr;
KWayland::Server::SeatInterface *m_seat = nullptr;
@ -223,6 +224,7 @@ private:
QThread *clientThread = nullptr;
KWayland::Client::Registry *registry = nullptr;
KWayland::Client::ShmPool *shm = nullptr;
bool interfacesAnnounced = false;
} m_internalConnection;
struct {