From 06d2a31bd393f6179953e3ca2153c4ac581bc480 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Wed, 10 Feb 2021 14:09:02 +0100 Subject: [PATCH] xwayland: Rename updateXauthorityFile and add error handling This renames updateXauthorityFile to writeXauthorityEntries as it doesn't actually update (i.e. change) anything, it just writes new ones. Error handling is introduced, to avoid that it continues silently without entries, which would cause all connections to fail. --- src/xwl/xwayland.cpp | 8 +++----- src/xwl/xwayland.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/xwl/xwayland.cpp b/src/xwl/xwayland.cpp index 25733daa11..bcee37fc2b 100644 --- a/src/xwl/xwayland.cpp +++ b/src/xwl/xwayland.cpp @@ -317,14 +317,12 @@ void Xwayland::handleXwaylandReady() m_watcher->deleteLater(); m_watcher = nullptr; - if (!createX11Connection()) { + if (!createX11Connection() || !writeXauthorityEntries()) { emit errorOccurred(); return; } const QByteArray displayName = ':' + QByteArray::number(m_display); - updateXauthorityFile(); - qCInfo(KWIN_XWL) << "Xwayland server started on display" << displayName; qputenv("DISPLAY", displayName); qputenv("XAUTHORITY", m_authorityFile.fileName().toUtf8()); @@ -435,7 +433,7 @@ static QByteArray generateXauthorityCookie() return cookie; } -void Xwayland::updateXauthorityFile() +bool Xwayland::writeXauthorityEntries() { const quint16 family = 256; // FamilyLocal @@ -449,7 +447,7 @@ void Xwayland::updateXauthorityFile() writeXauthorityEntry(stream, family, address, display, name, cookie); - m_authorityFile->flush(); + return stream.status() == QDataStream::Ok && m_authorityFile.flush(); } DragEventReply Xwayland::dragMoveFilter(Toplevel *target, const QPoint &pos) diff --git a/src/xwl/xwayland.h b/src/xwl/xwayland.h index b23321ce83..0bdbdbfdf5 100644 --- a/src/xwl/xwayland.h +++ b/src/xwl/xwayland.h @@ -99,7 +99,7 @@ private: void destroyX11Connection(); bool createXauthorityFile(); - void updateXauthorityFile(); + bool writeXauthorityEntries(); DragEventReply dragMoveFilter(Toplevel *target, const QPoint &pos) override;