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 <frederik.gladhorn@theqtcompany.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
bb10
Ulf Hermann 2015-11-23 11:57:58 +01:00
parent 4c29eba248
commit 1f2734b82b
3 changed files with 30 additions and 11 deletions

View File

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

View File

@ -626,7 +626,11 @@ private:
QMutex m_callLogMutex;
void log(const char *file, int line, int sequence);
template <typename cookie_t>
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 <typename reply_t>
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 <typename cookie_t>
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 <typename reply_t>
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__);

View File

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