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
This commit is contained in:
Martin Gräßlin 2013-02-14 08:39:56 +01:00
parent f45ade7785
commit e72fec3110

View file

@ -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