diff options
| author | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-06-16 18:37:59 +0900 |
|---|---|---|
| committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-06-18 11:15:00 +0900 |
| commit | 7dd4848d61e4c52091d6c644356c84c67536bde2 (patch) | |
| tree | b1f7e53a9d097ff41aaed87997b5f63c56bbfa7a | |
| parent | d4981524d7cb87bf2e100ee981ac0d082b79790b (diff) | |
| download | tqt-7dd4848d61e4c52091d6c644356c84c67536bde2.tar.gz tqt-7dd4848d61e4c52091d6c644356c84c67536bde2.zip | |
Fix handling of socket notifier events in gmainloop functions.
This resolves issue #231.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 2584dba8aabfa2db8297dcfa258d33545ed6af43)
| -rw-r--r-- | src/kernel/qeventloop_x11.cpp | 8 | ||||
| -rw-r--r-- | src/kernel/qeventloop_x11_glib.cpp | 21 |
2 files changed, 19 insertions, 10 deletions
diff --git a/src/kernel/qeventloop_x11.cpp b/src/kernel/qeventloop_x11.cpp index a907a11e1..0d3d6ee10 100644 --- a/src/kernel/qeventloop_x11.cpp +++ b/src/kernel/qeventloop_x11.cpp @@ -231,8 +231,11 @@ bool TQEventLoop::processEvents( ProcessEventsFlags flags ) } } + // Include or exclude SocketNotifiers (by setting or cleaning poll events) + // Socket notifier events are only activated in the core application event loop, + // so filter them out in other event loops. int highest = 0; - if ( ! ( flags & ExcludeSocketNotifiers ) ) { + if (!(flags & ExcludeSocketNotifiers) && TQApplication::isGuiThread()) { // return the highest fd we can wait for input on if ( d->sn_highest >= 0 ) { // has socket notifier(s) if ( d->sn_vec[0].list && ! d->sn_vec[0].list->isEmpty() ) @@ -370,7 +373,8 @@ bool TQEventLoop::processEvents( ProcessEventsFlags flags ) } // activate socket notifiers - if ( ! ( flags & ExcludeSocketNotifiers ) && nsel > 0 && d->sn_highest >= 0 ) { + if (!(flags & ExcludeSocketNotifiers) && nsel > 0 && d->sn_highest >= 0 && + TQApplication::isGuiThread()) { // if select says data is ready on any socket, then set the socket notifier // to pending int i; diff --git a/src/kernel/qeventloop_x11_glib.cpp b/src/kernel/qeventloop_x11_glib.cpp index 529ea08b2..c91475b92 100644 --- a/src/kernel/qeventloop_x11_glib.cpp +++ b/src/kernel/qeventloop_x11_glib.cpp @@ -419,8 +419,10 @@ bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout) } } - // include or exclude SocketNotifiers (by setting or cleaning poll events) - if ( ! ( flags & ExcludeSocketNotifiers ) ) { + // Include or exclude SocketNotifiers (by setting or cleaning poll events) + // Socket notifier events are only activated in the core application event loop, + // so filter them out in other event loops. + if (!(flags & ExcludeSocketNotifiers) && TQApplication::isGuiThread()) { TQPtrListIterator<TQSockNotGPollFD> it( d->sn_list ); TQSockNotGPollFD *sn; while ( (sn=it.current()) ) { @@ -491,17 +493,20 @@ bool TQEventLoop::gsourceCheck(GSource *gs) { printf("inside gsourceCheck(1)\n"); #endif + ProcessEventsFlags flags = d->pev_flags; + // Socketnotifier events? - TQPtrList<TQSockNotGPollFD> *list = &d->sn_list; - //if ( list ) { - TQSockNotGPollFD *sn = list->first(); - while ( sn ) { + if (!(flags & ExcludeSocketNotifiers) && TQApplication::isGuiThread()) + { + TQPtrListIterator<TQSockNotGPollFD> it( d->sn_list ); + TQSockNotGPollFD *sn; + while ( (sn=it.current()) ) { + ++it; if ( sn->gPollFD.revents ) { return TRUE; } - sn = list->next(); } - //} + } if (d->x_gPollFD.revents) { #ifdef DEBUG_QT_GLIBMAINLOOP |
