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
icc-effect-5.14.5
Martin Gräßlin 2014-04-10 10:24:42 +02:00
parent acdff6ea52
commit 1c0d0211ca
2 changed files with 12 additions and 1 deletions

View File

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

View File

@ -102,13 +102,24 @@ public:
getReply();
return m_reply == NULL;
}
inline bool isNull() const {
const_cast<Wrapper*>(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<Wrapper*>(this)->getReply();
return m_reply;
}
inline WindowId window() const {
return m_window;
}