From 018afd092acc006386fedd4bbf82f78b673c6c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Wed, 1 Nov 2017 15:09:40 +0100 Subject: [PATCH] Guard X11 access in supportInformation Caused crash when running KWin without X11 support. --- workspace.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/workspace.cpp b/workspace.cpp index 7bb57a1bc9..3364e2fcf8 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -1403,19 +1403,21 @@ QString Workspace::supportInformation() const #endif support.append(QStringLiteral("\n")); - support.append(QStringLiteral("X11\n")); - support.append(QStringLiteral("===\n")); - auto x11setup = xcb_get_setup(connection()); - support.append(QStringLiteral("Vendor: %1\n").arg(QString::fromUtf8(QByteArray::fromRawData(xcb_setup_vendor(x11setup), xcb_setup_vendor_length(x11setup))))); - support.append(QStringLiteral("Vendor Release: %1\n").arg(x11setup->release_number)); - support.append(QStringLiteral("Protocol Version/Revision: %1/%2\n").arg(x11setup->protocol_major_version).arg(x11setup->protocol_minor_version)); - const auto extensions = Xcb::Extensions::self()->extensions(); - for (const auto &e : extensions) { - support.append(QStringLiteral("%1: %2; Version: 0x%3\n").arg(QString::fromUtf8(e.name)) - .arg(e.present ? yes.trimmed() : no.trimmed()) - .arg(QString::number(e.version, 16))); + if (auto c = kwinApp()->x11Connection()) { + support.append(QStringLiteral("X11\n")); + support.append(QStringLiteral("===\n")); + auto x11setup = xcb_get_setup(c); + support.append(QStringLiteral("Vendor: %1\n").arg(QString::fromUtf8(QByteArray::fromRawData(xcb_setup_vendor(x11setup), xcb_setup_vendor_length(x11setup))))); + support.append(QStringLiteral("Vendor Release: %1\n").arg(x11setup->release_number)); + support.append(QStringLiteral("Protocol Version/Revision: %1/%2\n").arg(x11setup->protocol_major_version).arg(x11setup->protocol_minor_version)); + const auto extensions = Xcb::Extensions::self()->extensions(); + for (const auto &e : extensions) { + support.append(QStringLiteral("%1: %2; Version: 0x%3\n").arg(QString::fromUtf8(e.name)) + .arg(e.present ? yes.trimmed() : no.trimmed()) + .arg(QString::number(e.version, 16))); + } + support.append(QStringLiteral("\n")); } - support.append(QStringLiteral("\n")); if (auto bridge = Decoration::DecorationBridge::self()) { support.append(QStringLiteral("Decoration\n"));