Created
December 21, 2015 15:59
-
-
Save nexces/b764e9ef6e513626bea4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From b9fe51692f84a67b2efb1873bb959bea3f483b35 Mon Sep 17 00:00:00 2001 | |
From: Adrian 'Nexces' Piotrowicz <adrian.piotrowicz@sprint.pl> | |
Date: Sun, 20 Dec 2015 11:26:09 +0100 | |
Subject: [PATCH] Fix XembedSNIProxy always crashing on login. | |
BUG: 355463 | |
--- | |
xembed-sni-proxy/sniproxy.cpp | 17 ++++++++++++++--- | |
1 file changed, 14 insertions(+), 3 deletions(-) | |
diff --git a/xembed-sni-proxy/sniproxy.cpp b/xembed-sni-proxy/sniproxy.cpp | |
index ae6eab7..c132c64 100644 | |
--- a/xembed-sni-proxy/sniproxy.cpp | |
+++ b/xembed-sni-proxy/sniproxy.cpp | |
@@ -74,6 +74,13 @@ SNIProxy::SNIProxy(xcb_window_t wid, QObject* parent): | |
m_dbus(QDBusConnection::connectToBus(QDBusConnection::SessionBus, QStringLiteral("XembedSniProxy%1").arg(s_serviceCount++))), | |
m_windowId(wid) | |
{ | |
+ auto c = QX11Info::connection(); | |
+ | |
+ auto cookie = xcb_get_geometry(c, m_windowId); | |
+ QScopedPointer<xcb_get_geometry_reply_t> clientGeom(xcb_get_geometry_reply(c, cookie, Q_NULLPTR)); | |
+ | |
+ if (clientGeom && clientGeom->width > 0) { | |
+ | |
//create new SNI | |
new StatusNotifierItemAdaptor(this); | |
m_dbus.registerObject(QStringLiteral("/StatusNotifierItem"), this); | |
@@ -85,10 +92,7 @@ SNIProxy::SNIProxy(xcb_window_t wid, QObject* parent): | |
qCWarning(SNIPROXY) << "could not register SNI:" << reply.error().message(); | |
} | |
- auto c = QX11Info::connection(); | |
- auto cookie = xcb_get_geometry(c, m_windowId); | |
- QScopedPointer<xcb_get_geometry_reply_t> clientGeom(xcb_get_geometry_reply(c, cookie, Q_NULLPTR)); | |
//create a container window | |
auto screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data; | |
@@ -181,6 +185,7 @@ SNIProxy::SNIProxy(xcb_window_t wid, QObject* parent): | |
//not ideal, but it works better than nothing | |
//test with xchat before changing | |
QTimer::singleShot(500, this, &SNIProxy::update); | |
+ } | |
} | |
SNIProxy::~SNIProxy() | |
@@ -241,6 +246,12 @@ QImage SNIProxy::getImageNonComposite() const | |
auto cookie = xcb_get_geometry(c, m_windowId); | |
QScopedPointer<xcb_get_geometry_reply_t> geom(xcb_get_geometry_reply(c, cookie, Q_NULLPTR)); | |
+ QImage qimage; | |
+ if (!geom) { | |
+ // 0001-adapted from xembedsniproxy-fix-always-segfault.patch | |
+ return qimage; | |
+ } | |
+ | |
xcb_image_t *image = xcb_image_get(c, m_windowId, 0, 0, geom->width, geom->height, 0xFFFFFF, XCB_IMAGE_FORMAT_Z_PIXMAP); | |
// Don't hook up cleanup yet, we may use a different QImage after all | |
-- | |
2.4.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment