Make the function pointer to xcb_poll_for_queued_event not a member
In the normal case, this change is a no-op. In case RTLD_DEFAULT isn't defined, this makes the job of the optimizer easier to detect that the static variable is never modified and that it can do a lot of dead code elimination. This also enables the optimization in the next commit. Change-Id: Ib306f8f647014b399b87ffff13f12f40a359233b Reviewed-by: Gatis Paeglis <gatis.paeglis@digia.com>bb10
parent
2bcb2ce8c9
commit
0d7af31e83
|
|
@ -77,6 +77,21 @@
|
|||
#include <xcb/render.h>
|
||||
#endif
|
||||
|
||||
typedef xcb_generic_event_t * (*XcbPollForQueuedEventFunctionPointer)(xcb_connection_t *c);
|
||||
static XcbPollForQueuedEventFunctionPointer local_xcb_poll_for_queued_event;
|
||||
|
||||
static inline void checkXcbPollForQueuedEvent()
|
||||
{
|
||||
#ifdef RTLD_DEFAULT
|
||||
local_xcb_poll_for_queued_event = (XcbPollForQueuedEventFunctionPointer)dlsym(RTLD_DEFAULT, "xcb_poll_for_queued_event");
|
||||
#endif
|
||||
|
||||
#ifdef Q_XCB_DEBUG
|
||||
if (local_xcb_poll_for_queued_event)
|
||||
qDebug("Using threaded event reader with xcb_poll_for_queued_event");
|
||||
#endif
|
||||
}
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_LOGGING_CATEGORY(lcQpaXInput, "qt.qpa.input")
|
||||
|
|
@ -1169,21 +1184,13 @@ void QXcbConnection::addPeekFunc(PeekFunc f)
|
|||
|
||||
QXcbEventReader::QXcbEventReader(QXcbConnection *connection)
|
||||
: m_connection(connection)
|
||||
, m_xcb_poll_for_queued_event(0)
|
||||
{
|
||||
#ifdef RTLD_DEFAULT
|
||||
m_xcb_poll_for_queued_event = (XcbPollForQueuedEventFunctionPointer)dlsym(RTLD_DEFAULT, "xcb_poll_for_queued_event");
|
||||
#endif
|
||||
|
||||
#ifdef Q_XCB_DEBUG
|
||||
if (m_xcb_poll_for_queued_event)
|
||||
qDebug("Using threaded event reader with xcb_poll_for_queued_event");
|
||||
#endif
|
||||
checkXcbPollForQueuedEvent();
|
||||
}
|
||||
|
||||
void QXcbEventReader::start()
|
||||
{
|
||||
if (m_xcb_poll_for_queued_event) {
|
||||
if (local_xcb_poll_for_queued_event) {
|
||||
connect(this, SIGNAL(eventPending()), m_connection, SLOT(processXcbEvents()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(finished()), m_connection, SLOT(processXcbEvents()));
|
||||
QThread::start();
|
||||
|
|
@ -1209,7 +1216,7 @@ void QXcbEventReader::registerEventDispatcher(QAbstractEventDispatcher *dispatch
|
|||
// flush the xcb connection before the EventDispatcher is going to block
|
||||
// In the non-threaded case processXcbEvents is called before going to block,
|
||||
// which flushes the connection.
|
||||
if (m_xcb_poll_for_queued_event)
|
||||
if (local_xcb_poll_for_queued_event)
|
||||
connect(dispatcher, SIGNAL(aboutToBlock()), m_connection, SLOT(flush()));
|
||||
}
|
||||
|
||||
|
|
@ -1219,7 +1226,7 @@ void QXcbEventReader::run()
|
|||
while (m_connection && (event = xcb_wait_for_event(m_connection->xcb_connection()))) {
|
||||
m_mutex.lock();
|
||||
addEvent(event);
|
||||
while (m_connection && (event = m_xcb_poll_for_queued_event(m_connection->xcb_connection())))
|
||||
while (m_connection && (event = local_xcb_poll_for_queued_event(m_connection->xcb_connection())))
|
||||
addEvent(event);
|
||||
m_mutex.unlock();
|
||||
emit eventPending();
|
||||
|
|
@ -1243,7 +1250,7 @@ void QXcbEventReader::addEvent(xcb_generic_event_t *event)
|
|||
QXcbEventArray *QXcbEventReader::lock()
|
||||
{
|
||||
m_mutex.lock();
|
||||
if (!m_xcb_poll_for_queued_event) {
|
||||
if (!local_xcb_poll_for_queued_event) {
|
||||
while (xcb_generic_event_t *event = xcb_poll_for_event(m_connection->xcb_connection()))
|
||||
m_events << event;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -324,9 +324,6 @@ private:
|
|||
QMutex m_mutex;
|
||||
QXcbEventArray m_events;
|
||||
QXcbConnection *m_connection;
|
||||
|
||||
typedef xcb_generic_event_t * (*XcbPollForQueuedEventFunctionPointer)(xcb_connection_t *c);
|
||||
XcbPollForQueuedEventFunctionPointer m_xcb_poll_for_queued_event;
|
||||
};
|
||||
|
||||
class QXcbWindowEventListener
|
||||
|
|
|
|||
Loading…
Reference in New Issue