Terminate qApp before connections
AbandonedPublic

Authored by davidedmundson on May 6 2017, 9:00 PM.

Details

Reviewers
graesslin
Summary

This gives a reflective pattern:

  • start connections
  • qapp constructor ----
  • qapp destructor
  • terminate connections

This gives us a valid connection whilst we unload QStyle the QPA, and
any other child objects, and we don't need kwin special cases in Breeze.

WaylandServer is a singleton which will still exist till after this.

Diff Detail

Repository
R108 KWin
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
davidedmundson created this revision.May 6 2017, 9:00 PM
Restricted Application added a project: KWin. · View Herald TranscriptMay 6 2017, 9:00 PM
Restricted Application added subscribers: KWin, kwin. · View Herald Transcript

Rebased to master

graesslin requested changes to this revision.May 7 2017, 7:17 AM
graesslin added a subscriber: graesslin.

WaylandServer is a Qobject child of Application. Please be extremely careful with the destroying of the Wayland connection. I spent days in making the sequence so that asan doesn't complain any more.

This revision now requires changes to proceed.May 7 2017, 7:17 AM

Some additional information: terminateClientConnections needs to happen before we destroy the workspace and our compositor. The problem is that when we terminate the connections there is still cleanup code running through the protocol. E.g. if we have an internal QWindow (example Alt+Tab) the ShellClient for it will be destroyed when we terminate the client connection. Destroying the ShellClient interacts with Compositor and Workspace. Thus things might crash when going down. Thus the terminateClientConnection is exactly at that place prior to destroying the compositor to ensure it does not crash or access already freed memory.

Some brainstorming: we have here a special case in Breeze. In the usage in KWin the wayland connection is hold by the ConnectionThread and not by Qtwayland like in all other cases. But Breeze does not take any advantage of the fact that we have a "native" ConnectionThread. It has a copy of the ConnectionThread like always.

So an idea could be to do special casing in ConnectionThread. E.g. we could go through the QPA native interface protocol and return the ConnectionThread directly or we check when creating a ConnectionThread whether there is another ConnectionThread for the wl_connection which is native and setup a signal to terminate the others. Something like:

ConnectionThread *native = nativeConnection(wl_connection*);
connect(native, &ConnectionThread::aboutToBeReleased, this, &QObject::deleteLater);
davidedmundson abandoned this revision.Jun 5 2017, 12:08 PM