Revert "wayland: Terminate client connections before Workspace is destroyed"

Commit 826b9742e9 breaks a lot of other
things. Need further investigation before fixing heap-use-after-free.
This commit is contained in:
Vlad Zagorodniy 2019-08-07 11:21:30 +03:00
parent f1bbe935d3
commit 4e078b9eaf
5 changed files with 44 additions and 43 deletions

View file

@ -83,23 +83,18 @@ WaylandTestApplication::~WaylandTestApplication()
if (effects) { if (effects) {
static_cast<EffectsHandlerImpl*>(effects)->unloadAllEffects(); static_cast<EffectsHandlerImpl*>(effects)->unloadAllEffects();
} }
if (m_xwayland) {
// Kill Xwayland before terminating its connection. // needs to be done before workspace gets destroyed
delete m_xwayland; m_xwayland->prepareDestroy();
m_xwayland = nullptr; }
// Terminate all client connections before Workspace is destroyed.
// Shell clients need to access RuleBook whose lifetime is bound
// to the Workspace class.
waylandServer()->terminateClientConnections();
waylandServer()->dispatch();
destroyWorkspace(); destroyWorkspace();
waylandServer()->dispatch();
if (QStyle *s = style()) { if (QStyle *s = style()) {
s->unpolish(this); s->unpolish(this);
} }
// kill Xwayland before terminating its connection
delete m_xwayland;
waylandServer()->terminateClientConnections();
destroyCompositor(); destroyCompositor();
} }

View file

@ -128,23 +128,20 @@ ApplicationWayland::~ApplicationWayland()
if (effects) { if (effects) {
static_cast<EffectsHandlerImpl*>(effects)->unloadAllEffects(); static_cast<EffectsHandlerImpl*>(effects)->unloadAllEffects();
} }
if (m_xwayland) {
// Kill Xwayland before terminating its connection. // needs to be done before workspace gets destroyed
delete m_xwayland; m_xwayland->prepareDestroy();
m_xwayland = nullptr; }
// Terminate all client connections before Workspace is destroyed.
// Shell clients need to access RuleBook whose lifetime is bound
// to the Workspace class.
waylandServer()->terminateClientConnections();
waylandServer()->dispatch();
destroyWorkspace(); destroyWorkspace();
waylandServer()->dispatch();
if (QStyle *s = style()) { if (QStyle *s = style()) {
s->unpolish(this); s->unpolish(this);
} }
// kill Xwayland before terminating its connection
delete m_xwayland;
m_xwayland = nullptr;
waylandServer()->terminateClientConnections();
destroyCompositor(); destroyCompositor();
} }

View file

@ -425,9 +425,11 @@ void ShellClient::destroyClient()
if (isMoveResize()) { if (isMoveResize()) {
leaveMoveResize(); leaveMoveResize();
} }
Deleted *del = nullptr;
Deleted *deleted = Deleted::create(this); if (workspace()) {
emit windowClosed(this, deleted); del = Deleted::create(this);
}
emit windowClosed(this, del);
// Remove Force Temporarily rules. // Remove Force Temporarily rules.
RuleBook::self()->discardUsed(this, true); RuleBook::self()->discardUsed(this, true);
@ -435,22 +437,25 @@ void ShellClient::destroyClient()
destroyWindowManagementInterface(); destroyWindowManagementInterface();
destroyDecoration(); destroyDecoration();
StackingUpdatesBlocker blocker(workspace()); if (workspace()) {
if (transientFor()) { StackingUpdatesBlocker blocker(workspace());
transientFor()->removeTransient(this); if (transientFor()) {
} transientFor()->removeTransient(this);
for (auto it = transients().constBegin(); it != transients().constEnd();) { }
if ((*it)->transientFor() == this) { for (auto it = transients().constBegin(); it != transients().constEnd();) {
removeTransient(*it); if ((*it)->transientFor() == this) {
it = transients().constBegin(); // restart, just in case something more has changed with the list removeTransient(*it);
} else { it = transients().constBegin(); // restart, just in case something more has changed with the list
++it; } else {
++it;
}
} }
} }
waylandServer()->removeClient(this); waylandServer()->removeClient(this);
deleted->unrefWindow(); if (del) {
del->unrefWindow();
}
m_shellSurface = nullptr; m_shellSurface = nullptr;
m_xdgShellSurface = nullptr; m_xdgShellSurface = nullptr;
m_xdgShellPopup = nullptr; m_xdgShellPopup = nullptr;

View file

@ -88,9 +88,6 @@ Xwayland::Xwayland(ApplicationWaylandAbstract *app, QObject *parent)
Xwayland::~Xwayland() Xwayland::~Xwayland()
{ {
delete m_dataBridge;
m_dataBridge = nullptr;
disconnect(m_xwaylandFailConnection); disconnect(m_xwaylandFailConnection);
if (m_app->x11Connection()) { if (m_app->x11Connection()) {
Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT); Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT);
@ -181,6 +178,12 @@ void Xwayland::init()
close(pipeFds[1]); close(pipeFds[1]);
} }
void Xwayland::prepareDestroy()
{
delete m_dataBridge;
m_dataBridge = nullptr;
}
void Xwayland::createX11Connection() void Xwayland::createX11Connection()
{ {
int screenNumber = 0; int screenNumber = 0;

View file

@ -47,6 +47,7 @@ public:
~Xwayland() override; ~Xwayland() override;
void init(); void init();
void prepareDestroy();
xcb_screen_t *xcbScreen() const { xcb_screen_t *xcbScreen() const {
return m_xcbScreen; return m_xcbScreen;