Automated update from Qt3

pull/1/head
Timothy Pearson 12 years ago
parent 33e2cf2d1c
commit 5faba37f11

9
configure vendored

@ -734,9 +734,6 @@ while [ "$#" -gt 0 ]; do
glibmainloop) glibmainloop)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_GLIBMAINLOOP="$VAL" CFG_GLIBMAINLOOP="$VAL"
if [ "$VAL" = "yes" ]; then
echo "WARNING: glib main loop support is ***incomplete*** and will cause problems with threaded applications and/or those using non-standard event loops!"
fi
else else
UNKNOWN_OPT=yes UNKNOWN_OPT=yes
fi fi
@ -2644,13 +2641,11 @@ if [ "$CFG_GLIBMAINLOOP" = "no" ]; then
elif [ "$CFG_GLIBMAINLOOP" = "yes" ]; then elif [ "$CFG_GLIBMAINLOOP" = "yes" ]; then
QMAKE_CONFIG="$QMAKE_CONFIG glibmainloop" QMAKE_CONFIG="$QMAKE_CONFIG glibmainloop"
GLIB_CFLAGS="`pkg-config --cflags glib-2.0`" GLIB_CFLAGS="`pkg-config --cflags glib-2.0` `pkg-config --cflags gthread-2.0`"
QMAKE_VARS="$QMAKE_VARS \"QMAKE_CFLAGS_GLIB=$GLIB_CFLAGS\"" QMAKE_VARS="$QMAKE_VARS \"QMAKE_CFLAGS_GLIB=$GLIB_CFLAGS\""
GLIB_LINKFLAG="`pkg-config --libs glib-2.0`" GLIB_LINKFLAG="`pkg-config --libs glib-2.0` `pkg-config --libs gthread-2.0`"
QMAKE_VARS="$QMAKE_VARS \"QMAKE_LIBS_GLIB=$GLIB_LINKFLAG\"" QMAKE_VARS="$QMAKE_VARS \"QMAKE_LIBS_GLIB=$GLIB_LINKFLAG\""
fi fi
if [ "$CFG_GIF" = "no" ]; then if [ "$CFG_GIF" = "no" ]; then
QMAKE_CONFIG="$QMAKE_CONFIG no-gif" QMAKE_CONFIG="$QMAKE_CONFIG no-gif"

@ -223,8 +223,9 @@ int TQEventLoop::enterLoop()
d->shortcut = FALSE; d->shortcut = FALSE;
d->looplevel++; d->looplevel++;
while ( ! d->exitloop ) while ( ! d->exitloop ) {
processEvents( AllEvents | WaitForMore ); processEvents( AllEvents | WaitForMore );
}
d->looplevel--; d->looplevel--;
// restore the exitloop state, but if quitnow is TRUE, we need to keep // restore the exitloop state, but if quitnow is TRUE, we need to keep

@ -54,6 +54,7 @@
#include <errno.h> #include <errno.h>
#include <glib.h> #include <glib.h>
#include <sys/syscall.h>
// #define DEBUG_QT_GLIBMAINLOOP 1 // #define DEBUG_QT_GLIBMAINLOOP 1
@ -109,7 +110,7 @@ static gboolean qt_gsource_check ( GSource *source )
} }
} }
static gboolean qt_gsource_dispatch ( GSource *source, GSourceFunc callback, gpointer user_data ) static gboolean qt_gsource_dispatch ( GSource *source, GSourceFunc callback, gpointer user_data )
{ {
Q_UNUSED(callback); Q_UNUSED(callback);
Q_UNUSED(user_data); Q_UNUSED(user_data);
@ -195,7 +196,7 @@ void qt_remove_postselect_handler( VFPTR handler )
void TQEventLoop::init() void TQEventLoop::init()
{ {
// initialize ProcessEventFlags (all events & wait for more) // initialize ProcessEventFlags (all events & wait for more)
d->pev_flags = AllEvents | WaitForMore; d->pev_flags = AllEvents | WaitForMore;
// initialize the common parts of the event loop // initialize the common parts of the event loop
if (pipe( d->thread_pipe ) < 0) { if (pipe( d->thread_pipe ) < 0) {
@ -239,13 +240,12 @@ void TQEventLoop::init()
// poll thread-pipe // poll thread-pipe
d->threadPipe_gPollFD.fd = d->thread_pipe[0]; d->threadPipe_gPollFD.fd = d->thread_pipe[0];
d->threadPipe_gPollFD.events = G_IO_IN | G_IO_HUP | G_IO_ERR; d->threadPipe_gPollFD.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
g_source_add_poll(d->gSource, &d->threadPipe_gPollFD); g_source_add_poll(d->gSource, &d->threadPipe_gPollFD);
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside init(2)\n"); printf("inside init(2)\n");
#endif #endif
} }
void TQEventLoop::cleanup() void TQEventLoop::cleanup()
@ -266,25 +266,24 @@ void TQEventLoop::cleanup()
bool TQEventLoop::processEvents( ProcessEventsFlags flags ) bool TQEventLoop::processEvents( ProcessEventsFlags flags )
{ {
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside processEvents(1) looplevel=%d\n", d->looplevel ); printf("inside processEvents(1) looplevel=%d eventloop=%p d->ctx=%p this=%p\n", d->looplevel, TQApplication::eventLoop(), d->ctx, this ); fflush(stdout);
#endif #endif
ProcessEventsFlags save_flags; ProcessEventsFlags save_flags;
int rval; int rval;
save_flags = d->pev_flags; save_flags = d->pev_flags;
d->pev_flags = flags; d->pev_flags = flags;
rval = g_main_context_iteration(d->ctx, flags & WaitForMore ? TRUE : FALSE); rval = g_main_context_iteration(d->ctx, flags & WaitForMore ? TRUE : FALSE);
d->pev_flags = save_flags; d->pev_flags = save_flags;
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside processEvents(2) looplevel=%d rval=%d\n", d->looplevel, rval ); printf("inside processEvents(2) looplevel=%d eventloop=%p d->ctx=%p this=%p rval=%d\n", d->looplevel, TQApplication::eventLoop(), d->ctx, this, rval ); fflush(stdout);
#endif #endif
return rval; // were events processed? return rval; // were events processed?
} }
@ -312,9 +311,9 @@ bool TQEventLoop::processX11Events()
if ( d->shortcut ) { if ( d->shortcut ) {
return FALSE; return FALSE;
} }
XNextEvent( TQPaintDevice::x11AppDisplay(), &event ); XNextEvent( TQPaintDevice::x11AppDisplay(), &event );
if ( flags & ExcludeUserInput ) { if ( flags & ExcludeUserInput ) {
switch ( event.type ) { switch ( event.type ) {
case ButtonPress: case ButtonPress:
@ -325,31 +324,31 @@ bool TQEventLoop::processX11Events()
case EnterNotify: case EnterNotify:
case LeaveNotify: case LeaveNotify:
continue; continue;
case ClientMessage: case ClientMessage:
{ {
// from qapplication_x11.cpp // from qapplication_x11.cpp
extern Atom tqt_wm_protocols; extern Atom tqt_wm_protocols;
extern Atom tqt_wm_take_focus; extern Atom tqt_wm_take_focus;
extern Atom qt_qt_scrolldone; extern Atom qt_qt_scrolldone;
// only keep the wm_take_focus and // only keep the wm_take_focus and
// qt_qt_scrolldone protocols, discard all // qt_qt_scrolldone protocols, discard all
// other client messages // other client messages
if ( event.xclient.format != 32 ) if ( event.xclient.format != 32 )
continue; continue;
if ( event.xclient.message_type == tqt_wm_protocols || if ( event.xclient.message_type == tqt_wm_protocols ||
(Atom) event.xclient.data.l[0] == tqt_wm_take_focus ) (Atom) event.xclient.data.l[0] == tqt_wm_take_focus )
break; break;
if ( event.xclient.message_type == qt_qt_scrolldone ) if ( event.xclient.message_type == qt_qt_scrolldone )
break; break;
} }
default: break; default: break;
} }
} }
nevents++; nevents++;
if ( tqApp->x11ProcessEvent( &event ) == 1 ) { if ( tqApp->x11ProcessEvent( &event ) == 1 ) {
return TRUE; return TRUE;
@ -358,13 +357,13 @@ bool TQEventLoop::processX11Events()
} }
} }
} }
if ( d->shortcut ) { if ( d->shortcut ) {
return FALSE; return FALSE;
} }
TQApplication::sendPostedEvents(); TQApplication::sendPostedEvents();
const uint exclude_all = ExcludeSocketNotifiers | 0x08; const uint exclude_all = ExcludeSocketNotifiers | 0x08;
// 0x08 == ExcludeTimers for X11 only // 0x08 == ExcludeTimers for X11 only
if ( nevents > 0 && ( flags & exclude_all ) == exclude_all && ( flags & WaitForMore ) ) { if ( nevents > 0 && ( flags & exclude_all ) == exclude_all && ( flags & WaitForMore ) ) {
@ -372,27 +371,27 @@ bool TQEventLoop::processX11Events()
} }
return FALSE; return FALSE;
} }
bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout) bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
{ {
Q_UNUSED(gs); Q_UNUSED(gs);
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(1)\n"); printf("inside gsourcePrepare(1)\n");
#endif #endif
ProcessEventsFlags flags = d->pev_flags; ProcessEventsFlags flags = d->pev_flags;
#if defined(QT_THREAD_SUPPORT) #if defined(QT_THREAD_SUPPORT)
TQMutexLocker locker( TQApplication::tqt_mutex ); TQMutexLocker locker( TQApplication::tqt_mutex );
#endif #endif
// don't block if exitLoop() or exit()/quit() has been called. // don't block if exitLoop() or exit()/quit() has been called.
bool canWait = d->exitloop || d->quitnow ? FALSE : (flags & WaitForMore); bool canWait = d->exitloop || d->quitnow ? FALSE : (flags & WaitForMore);
// Process timers and socket notifiers - the common UNIX stuff // Process timers and socket notifiers - the common UNIX stuff
// return the maximum time we can wait for an event. // return the maximum time we can wait for an event.
static timeval zerotm; static timeval zerotm;
timeval *tm = 0; timeval *tm = 0;
@ -406,13 +405,13 @@ bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
tm->tv_usec = 0; tm->tv_usec = 0;
} }
} }
// include or exclude SocketNotifiers (by setting or cleaning poll events) // include or exclude SocketNotifiers (by setting or cleaning poll events)
if ( ! ( flags & ExcludeSocketNotifiers ) ) { if ( ! ( flags & ExcludeSocketNotifiers ) ) {
TQPtrListIterator<TQSockNotGPollFD> it( d->sn_list ); TQPtrListIterator<TQSockNotGPollFD> it( d->sn_list );
TQSockNotGPollFD *sn; TQSockNotGPollFD *sn;
while ( (sn=it.current()) ) { while ( (sn=it.current()) ) {
++it; ++it;
sn->gPollFD.events = sn->events; // restore poll events sn->gPollFD.events = sn->events; // restore poll events
} }
} }
@ -420,7 +419,7 @@ bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
TQPtrListIterator<TQSockNotGPollFD> it( d->sn_list ); TQPtrListIterator<TQSockNotGPollFD> it( d->sn_list );
TQSockNotGPollFD *sn; TQSockNotGPollFD *sn;
while ( (sn=it.current()) ) { while ( (sn=it.current()) ) {
++it; ++it;
sn->gPollFD.events = 0; // delete poll events sn->gPollFD.events = 0; // delete poll events
} }
} }
@ -428,7 +427,7 @@ bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(2) canwait=%d\n", canWait); printf("inside gsourcePrepare(2) canwait=%d\n", canWait);
#endif #endif
if ( canWait ) { if ( canWait ) {
emit aboutToBlock(); emit aboutToBlock();
} }
@ -442,7 +441,7 @@ bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(2.1) canwait=%d\n", canWait); printf("inside gsourcePrepare(2.1) canwait=%d\n", canWait);
#endif #endif
// do we have to dispatch events? // do we have to dispatch events?
if (hasPendingEvents()) { if (hasPendingEvents()) {
*timeout = 0; // no time to stay in poll *timeout = 0; // no time to stay in poll
@ -451,7 +450,7 @@ bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
#endif #endif
return FALSE; return FALSE;
} }
// stay in poll until something happens? // stay in poll until something happens?
if (!tm) { // fixme if (!tm) { // fixme
*timeout = -1; // wait forever *timeout = -1; // wait forever
@ -460,10 +459,10 @@ bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
#endif #endif
return FALSE; return FALSE;
} }
// else timeout >=0 // else timeout >=0
*timeout = tm->tv_sec * 1000 + tm->tv_usec/1000; *timeout = tm->tv_sec * 1000 + tm->tv_usec/1000;
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(3c) timeout=%d \n", *timeout); printf("inside gsourcePrepare(3c) timeout=%d \n", *timeout);
#endif #endif
@ -519,7 +518,7 @@ bool TQEventLoop::gsourceCheck(GSource *gs) {
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) qtwaittimer!\n"); printf("inside gsourceCheck(2) qtwaittimer!\n");
#endif #endif
return TRUE; return TRUE;
} }
@ -553,10 +552,10 @@ bool TQEventLoop::gsourceDispatch(GSource *gs) {
// we are awake, broadcast it // we are awake, broadcast it
emit awake(); emit awake();
emit tqApp->guiThreadAwake(); emit tqApp->guiThreadAwake();
// some other thread woke us up... consume the data on the thread pipe so that // some other thread woke us up... consume the data on the thread pipe so that
// select doesn't immediately return next time // select doesn't immediately return next time
if ( d->threadPipe_gPollFD.revents) { if ( d->threadPipe_gPollFD.revents) {
char c; char c;
if (::read( d->thread_pipe[0], &c, 1 ) < 0) { if (::read( d->thread_pipe[0], &c, 1 ) < 0) {
@ -666,4 +665,4 @@ void TQEventLoop::setSingleToolkitEventHandling(bool enabled) {
d->ctx_is_default = true; d->ctx_is_default = true;
} }
} }
} }

@ -51,10 +51,12 @@ typedef pthread_mutex_t Q_MUTEX_T;
#include <errno.h> #include <errno.h>
#include <sched.h> #include <sched.h>
#if defined(QT_USE_GLIBMAINLOOP)
#include <glib.h>
#endif // QT_USE_GLIBMAINLOOP
static TQMutexPool *qt_thread_mutexpool = 0; static TQMutexPool *qt_thread_mutexpool = 0;
#if defined(Q_C_CALLBACKS) #if defined(Q_C_CALLBACKS)
extern "C" { extern "C" {
#endif #endif
@ -121,6 +123,11 @@ void *TQThreadInstance::start( void *_arg )
{ {
void **arg = (void **) _arg; void **arg = (void **) _arg;
#if defined(QT_USE_GLIBMAINLOOP)
// This is the first time we have access to the native pthread ID of this newly created thread
((TQThreadInstance*)arg[1])->thread_id = pthread_self();
#endif // QT_USE_GLIBMAINLOOP
setCurrentThread( (TQThread *) arg[0] ); setCurrentThread( (TQThread *) arg[0] );
pthread_cleanup_push( TQThreadInstance::finish, arg[1] ); pthread_cleanup_push( TQThreadInstance::finish, arg[1] );
@ -390,6 +397,20 @@ void TQThread::start(Priority priority)
d->args[0] = this; d->args[0] = this;
d->args[1] = d; d->args[1] = d;
#if defined(QT_USE_GLIBMAINLOOP)
// Legacy glib versions require this threading system initialization call
g_thread_init(NULL);
GThread* glib_thread_handle = g_thread_create((GThreadFunc)TQThreadInstance::start, d->args, false, NULL);
if (glib_thread_handle) {
ret = 0;
}
else {
ret = -1;
}
// The correct thread_id is set in TQThreadInstance::start using the value of d->args[1]
d->thread_id = NULL;
#else // QT_USE_GLIBMAINLOOP
ret = pthread_create( &d->thread_id, &attr, (TQtThreadCallback)TQThreadInstance::start, d->args ); ret = pthread_create( &d->thread_id, &attr, (TQtThreadCallback)TQThreadInstance::start, d->args );
#if defined (Q_OS_HPUX) #if defined (Q_OS_HPUX)
if (ret == EPERM) { if (ret == EPERM) {
@ -398,6 +419,7 @@ void TQThread::start(Priority priority)
} }
#endif #endif
pthread_attr_destroy( &attr ); pthread_attr_destroy( &attr );
#endif // QT_USE_GLIBMAINLOOP
if ( ret ) { if ( ret ) {
#ifdef QT_CHECK_STATE #ifdef QT_CHECK_STATE
@ -444,8 +466,9 @@ bool TQThread::wait( unsigned long time )
return FALSE; return FALSE;
} }
if ( d->finished || ! d->running ) if ( d->finished || ! d->running ) {
return TRUE; return TRUE;
}
int ret; int ret;
if (time != ULONG_MAX) { if (time != ULONG_MAX) {
@ -458,12 +481,15 @@ bool TQThread::wait( unsigned long time )
ti.tv_nsec %= 1000000000; ti.tv_nsec %= 1000000000;
ret = pthread_cond_timedwait(&d->thread_done, &locker.mutex()->d->handle, &ti); ret = pthread_cond_timedwait(&d->thread_done, &locker.mutex()->d->handle, &ti);
} else }
else {
ret = pthread_cond_wait(&d->thread_done, &locker.mutex()->d->handle); ret = pthread_cond_wait(&d->thread_done, &locker.mutex()->d->handle);
}
#ifdef QT_CHECK_RANGE #ifdef QT_CHECK_RANGE
if (ret && ret != ETIMEDOUT) if (ret && ret != ETIMEDOUT) {
tqWarning("Wait condition wait failure: %s",strerror(ret)); tqWarning("Wait condition wait failure: %s",strerror(ret));
}
#endif #endif
return (ret == 0); return (ret == 0);

Loading…
Cancel
Save