OSDN Git Service

use ConnectionNumber() macro instead of XConnectionNumber() function call
authorIvailo Monev <xakepa10@gmail.com>
Thu, 21 Jan 2021 19:50:00 +0000 (21:50 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Thu, 21 Jan 2021 19:50:00 +0000 (21:50 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/kernel/qabstracteventdispatcher.cpp
src/core/kernel/qabstracteventdispatcher.h
src/core/kernel/qcoreapplication.cpp
src/core/thread/qthread_unix.cpp
src/gui/kernel/qapplication.cpp
src/gui/kernel/qeventdispatcher_x11.cpp
src/gui/kernel/qeventdispatcher_x11_p.h

index d276347..818ca29 100644 (file)
@@ -421,16 +421,6 @@ int QAbstractEventDispatcher::registerTimer(int interval, QObject *object)
     immediately. Does nothing on platforms other than X11.
 */
 
-// ### DOC: Are these called when the _application_ starts/stops or just
-// when the current _event loop_ starts/stops?
-/*! \internal */
-void QAbstractEventDispatcher::startingUp()
-{ }
-
-/*! \internal */
-void QAbstractEventDispatcher::closingDown()
-{ }
-
 /*!
     \typedef QAbstractEventDispatcher::TimerInfo
 
index 24737b7..f76ec64 100644 (file)
@@ -72,9 +72,6 @@ public:
     virtual void interrupt() = 0;
     virtual void flush() = 0;
 
-    virtual void startingUp();
-    virtual void closingDown();
-
     typedef bool(*EventFilter)(void *message);
     EventFilter setEventFilter(EventFilter filter);
     bool filterEvent(void *message);
index bace146..95cf95d 100644 (file)
@@ -305,8 +305,6 @@ QCoreApplication::QCoreApplication(QCoreApplicationPrivate &p)
     : QObject(p, 0)
 {
     init();
-    // note: it is the subclasses' job to call
-    // QCoreApplicationPrivate::eventDispatcher->startingUp();
 }
 
 /*!
@@ -345,7 +343,6 @@ QCoreApplication::QCoreApplication(int &argc, char **argv)
 : QObject(*new QCoreApplicationPrivate(argc, argv))
 {
     init();
-    d_func()->threadData->eventDispatcher->startingUp();
 }
 
 
@@ -406,9 +403,6 @@ QCoreApplication::~QCoreApplication()
         globalThreadPool->waitForDone();
 #endif
 
-    if (d->threadData->eventDispatcher)
-        d->threadData->eventDispatcher->closingDown();
-
 #ifndef QT_NO_LIBRARY
     delete coreappdata()->app_libpaths;
     coreappdata()->app_libpaths = 0;
index 75effe5..24b8ec6 100644 (file)
@@ -153,11 +153,7 @@ void QAdoptedThread::init()
 void QThreadPrivate::createEventDispatcher(QThreadData *data)
 {
     QMutexLocker l(&data->postEventList.mutex);
-
     data->eventDispatcher = new QEventDispatcherUNIX;
-
-    l.unlock();
-    data->eventDispatcher->startingUp();
 }
 
 #ifndef QT_NO_THREAD
@@ -231,7 +227,6 @@ void QThreadPrivate::finish(void *arg)
     if (eventDispatcher) {
         d->data->eventDispatcher = Q_NULLPTR;
         locker.unlock();
-        eventDispatcher->closingDown();
         delete eventDispatcher;
         locker.relock();
     }
index ca0c1df..9c7060f 100644 (file)
@@ -604,8 +604,6 @@ void QApplicationPrivate::construct(
     if (qt_is_gui_used)
         initializeMultitouch();
 
-    threadData->eventDispatcher->startingUp();
-
 #ifndef QT_NO_LIBRARY
     //make sure the plugin is loaded
     if (qt_is_gui_used)
@@ -747,7 +745,6 @@ QApplication::~QApplication()
     d->toolTipWakeUp.stop();
     d->toolTipFallAsleep.stop();
 
-    d->threadData->eventDispatcher->closingDown();
     QApplicationPrivate::is_app_closing = true;
     QApplicationPrivate::is_app_running = false;
 
index c68f09c..cd49eca 100644 (file)
@@ -45,10 +45,6 @@ class QEventDispatcherX11Private : public QEventDispatcherUNIXPrivate
 {
     Q_DECLARE_PUBLIC(QEventDispatcherX11)
 public:
-    inline QEventDispatcherX11Private()
-        : xfd(-1)
-    { }
-    int xfd;
     QList<XEvent> queuedUserInputEvents;
 };
 
@@ -153,25 +149,14 @@ void QEventDispatcherX11::flush()
     XFlush(qt_x11Data->display);
 }
 
-void QEventDispatcherX11::startingUp()
-{
-    Q_D(QEventDispatcherX11);
-    d->xfd = XConnectionNumber(qt_x11Data->display);
-}
-
-void QEventDispatcherX11::closingDown()
-{
-    Q_D(QEventDispatcherX11);
-    d->xfd = -1;
-}
-
 int QEventDispatcherX11::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
                                 timeval *timeout)
 {
     Q_D(QEventDispatcherX11);
-    if (d->xfd > 0) {
-        nfds = qMax(nfds - 1, d->xfd) + 1;
-        FD_SET(d->xfd, readfds);
+    int xfd = ConnectionNumber(qt_x11Data->display);
+    if (Q_LIKELY(xfd > 0)) {
+        nfds = qMax(nfds - 1, xfd) + 1;
+        FD_SET(xfd, readfds);
     }
     return QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout);
 }
index 3a440a0..b906ec8 100644 (file)
@@ -65,9 +65,6 @@ public:
 
     void flush();
 
-    void startingUp();
-    void closingDown();
-
 protected:
     int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
                timeval *timeout);