From e72fec3110b9a3bddead023b60cee73b0373bf4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 14 Feb 2013 08:39:56 +0100 Subject: [PATCH] Cache the xcb_connection_t* in connection() This is for two reasons: 1. Fixes crash on tear-down when XGetXCBConnection returns junk 2. In Qt5 getting the connection is not cheap enough for our uses REVIEW: 108826 --- libkwineffects/kwinglobals.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libkwineffects/kwinglobals.h b/libkwineffects/kwinglobals.h index b1894e59ba..dba432432f 100644 --- a/libkwineffects/kwinglobals.h +++ b/libkwineffects/kwinglobals.h @@ -138,7 +138,11 @@ KWIN_EXPORT Display* display() inline KWIN_EXPORT xcb_connection_t *connection() { - return XGetXCBConnection(display()); + static xcb_connection_t *s_con = NULL; + if (!s_con) { + s_con = XGetXCBConnection(display()); + } + return s_con; } inline