From 1f2734b82b77fc8a959fdca8f3372cf09f65edd8 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 23 Nov 2015 11:57:58 +0100 Subject: Xcb: Fix debugging code We need to pass the correct connection and we need a specialization for reply pointers. Also, there is not much of a point in first creating a QString from a QByteArray, only to retrieve a QByteArray again. Change-Id: Ia1bb5655f6229638e3bd2339acadeffc80561b9e Reviewed-by: Frederik Gladhorn Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection.cpp | 11 +++++++---- src/plugins/platforms/xcb/qxcbconnection.h | 16 ++++++++++++++-- src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 14 +++++++++----- 3 files changed, 30 insertions(+), 11 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index ff39b24e93..1d20432bd4 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -934,17 +934,20 @@ void QXcbConnection::handleXcbError(xcb_generic_error_t *error) int i = 0; for (; i < m_callLog.size(); ++i) { if (m_callLog.at(i).sequence == error->sequence) { - qDebug("Caused by: %s:%d", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); + qDebug("Caused by: %s:%d", m_callLog.at(i).file.constData(), m_callLog.at(i).line); break; } else if (m_callLog.at(i).sequence > error->sequence) { - qDebug("Caused some time before: %s:%d", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); + qDebug("Caused some time before: %s:%d", m_callLog.at(i).file.constData(), + m_callLog.at(i).line); if (i > 0) - qDebug("and after: %s:%d", qPrintable(m_callLog.at(i-1).file), m_callLog.at(i-1).line); + qDebug("and after: %s:%d", m_callLog.at(i-1).file.constData(), + m_callLog.at(i-1).line); break; } } if (i == m_callLog.size() && !m_callLog.isEmpty()) - qDebug("Caused some time after: %s:%d", qPrintable(m_callLog.first().file), m_callLog.first().line); + qDebug("Caused some time after: %s:%d", m_callLog.first().file.constData(), + m_callLog.first().line); #endif } diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 3c82170679..cf50076f98 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -626,7 +626,11 @@ private: QMutex m_callLogMutex; void log(const char *file, int line, int sequence); template - friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line); + friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, + const char *file, int line); + template + friend reply_t *q_xcb_call_template(reply_t *reply, QXcbConnection *connection, + const char *file, int line); #endif WindowMapper m_mapper; @@ -689,11 +693,19 @@ private: #ifdef Q_XCB_DEBUG template -cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line) +cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, + int line) { connection->log(file, line, cookie.sequence); return cookie; } + +template +reply_t *q_xcb_call_template(reply_t *reply, QXcbConnection *connection, const char *file, int line) +{ + connection->log(file, line, reply->sequence); + return reply; +} #define Q_XCB_CALL(x) q_xcb_call_template(x, connection(), __FILE__, __LINE__) #define Q_XCB_CALL2(x, connection) q_xcb_call_template(x, connection, __FILE__, __LINE__) #define Q_XCB_NOOP(c) q_xcb_call_template(xcb_no_operation(c->xcb_connection()), c, __FILE__, __LINE__); diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index dfb0a125e2..374eaa4d6e 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -444,11 +444,15 @@ void *QXcbNativeInterface::atspiBus() QXcbConnection *defaultConnection = integration->defaultConnection(); if (defaultConnection) { xcb_atom_t atspiBusAtom = defaultConnection->internAtom("AT_SPI_BUS"); - xcb_get_property_cookie_t cookie = Q_XCB_CALL(xcb_get_property(defaultConnection->xcb_connection(), false, - defaultConnection->rootWindow(), - atspiBusAtom, - XCB_ATOM_STRING, 0, 128)); - xcb_get_property_reply_t *reply = Q_XCB_CALL(xcb_get_property_reply(defaultConnection->xcb_connection(), cookie, 0)); + xcb_get_property_cookie_t cookie = Q_XCB_CALL2(xcb_get_property( + defaultConnection->xcb_connection(), + false, defaultConnection->rootWindow(), + atspiBusAtom, XCB_ATOM_STRING, 0, 128), + defaultConnection); + xcb_get_property_reply_t *reply = Q_XCB_CALL2(xcb_get_property_reply( + defaultConnection->xcb_connection(), + cookie, 0), + defaultConnection); Q_ASSERT(!reply->bytes_after); char *data = (char *)xcb_get_property_value(reply); int length = xcb_get_property_value_length(reply); -- cgit v1.2.3