summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbconnection.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-07-15 10:35:10 -0700
committerThiago Macieira <thiago.macieira@intel.com>2015-07-28 21:12:31 +0000
commit0d7af31e83ec2de324546558e5c787e1d489cf5c (patch)
treec2fd6617892cfafdc1ec3a45d8682b458fb9e9df /src/plugins/platforms/xcb/qxcbconnection.cpp
parent2bcb2ce8c976de7daea71cab7d2215fc1ce5a448 (diff)
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>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 29e1fd145d..2158300591 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -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;
}