From 1c0d0211ca97d417bb351b426b8fe4d0e7bafdb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 10 Apr 2014 10:24:42 +0200 Subject: [PATCH] Add const method variants to Xcb::Wrapper Adding a const variant for ::data() to remove an unexpected copy. To complete also the bool cast operator and isNull get a const variant. REVIEW: 117469 --- workspace.cpp | 2 +- xcbutils.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/workspace.cpp b/workspace.cpp index 2ebf21d04a..8840591699 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -351,7 +351,7 @@ void Workspace::init() createUnmanaged(wins[i]); } else if (attr->map_state != XCB_MAP_STATE_UNMAPPED) { if (Application::wasCrash()) { - fixPositionAfterCrash(wins[i], windowGeometries[i].data()); + fixPositionAfterCrash(wins[i], windowGeometries.at(i).data()); } // ### This will request the attributes again diff --git a/xcbutils.h b/xcbutils.h index 5359fd1166..baa507fc51 100644 --- a/xcbutils.h +++ b/xcbutils.h @@ -102,13 +102,24 @@ public: getReply(); return m_reply == NULL; } + inline bool isNull() const { + const_cast(this)->getReply(); + return m_reply == NULL; + } inline operator bool() { return !isNull(); } + inline operator bool() const { + return !isNull(); + } inline const Reply *data() { getReply(); return m_reply; } + inline const Reply *data() const { + const_cast(this)->getReply(); + return m_reply; + } inline WindowId window() const { return m_window; }