diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-05-14 19:35:54 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-05-14 19:35:54 -0500 |
commit | 9a4765a62e321af08ec96a03cdbef64039788e86 (patch) | |
tree | fd261fdcf042d490030a2a1d337cf1b7cc8b514f /src/kernel/qeventloop_unix_glib.cpp | |
parent | c740211ffba3330d951f4c3ddefea8edf23a01cd (diff) | |
download | tqt3-9a4765a62e321af08ec96a03cdbef64039788e86.tar.gz tqt3-9a4765a62e321af08ec96a03cdbef64039788e86.zip |
Automated update from Qt3
Diffstat (limited to 'src/kernel/qeventloop_unix_glib.cpp')
-rw-r--r-- | src/kernel/qeventloop_unix_glib.cpp | 82 |
1 files changed, 51 insertions, 31 deletions
diff --git a/src/kernel/qeventloop_unix_glib.cpp b/src/kernel/qeventloop_unix_glib.cpp index 66bbcada0..1decd8f1b 100644 --- a/src/kernel/qeventloop_unix_glib.cpp +++ b/src/kernel/qeventloop_unix_glib.cpp @@ -55,6 +55,12 @@ #include <glib.h> +#ifdef QT_THREAD_SUPPORT +#ifdef QT_USE_GLIBMAINLOOP +extern TQMutex *tqt_timerListMutex; +#endif // QT_USE_GLIBMAINLOOP +#endif // QT_THREAD_SUPPORT + /***************************************************************************** Timer handling; UNIX has no application timer support so we'll have to make our own from scratch. @@ -102,9 +108,6 @@ typedef TQPtrList<TimerInfo> TimerList; // list of TimerInfo structs static TQBitArray *timerBitVec; // timer bit vector static TimerList *timerList = 0; // timer list -#if defined(QT_THREAD_SUPPORT) -static TQMutex *timerListMutex = 0; // timer list mutex -#endif static void initTimers(); void cleanupTimers(); @@ -184,7 +187,7 @@ static int allocTimerId() // find avail timer identifier static void insertTimer( const TimerInfo *ti ) // insert timer info into list { #if defined(QT_THREAD_SUPPORT) - timerListMutex->lock(); + tqt_timerListMutex->lock(); #endif TimerInfo *t = timerList->first(); int index = 0; @@ -207,7 +210,7 @@ static void insertTimer( const TimerInfo *ti ) // insert timer info into list } #endif #if defined(QT_THREAD_SUPPORT) - timerListMutex->unlock(); + tqt_timerListMutex->unlock(); #endif } @@ -233,7 +236,7 @@ static inline void getTime( timeval &t ) // get time of day static void repairTimer( const timeval &time ) // repair broken timer { #if defined(QT_THREAD_SUPPORT) - timerListMutex->lock(); + tqt_timerListMutex->lock(); #endif timeval diff = watchtime - time; register TimerInfo *t = timerList->first(); @@ -242,7 +245,7 @@ static void repairTimer( const timeval &time ) // repair broken timer t = timerList->next(); } #if defined(QT_THREAD_SUPPORT) - timerListMutex->unlock(); + tqt_timerListMutex->unlock(); #endif } @@ -260,7 +263,7 @@ static void repairTimer( const timeval &time ) // repair broken timer timeval *qt_wait_timer() { #if defined(QT_THREAD_SUPPORT) - if (timerListMutex) timerListMutex->lock(); + tqt_timerListMutex->lock(); #endif static timeval tm; bool first = TRUE; @@ -286,19 +289,19 @@ timeval *qt_wait_timer() tm = *qt_wait_timer_max; } #if defined(QT_THREAD_SUPPORT) - if (timerListMutex) timerListMutex->unlock(); + tqt_timerListMutex->unlock(); #endif return &tm; } if ( qt_wait_timer_max ) { tm = *qt_wait_timer_max; #if defined(QT_THREAD_SUPPORT) - if (timerListMutex) timerListMutex->unlock(); + tqt_timerListMutex->unlock(); #endif return &tm; } #if defined(QT_THREAD_SUPPORT) - if (timerListMutex) timerListMutex->unlock(); + tqt_timerListMutex->unlock(); #endif return 0; // no timers } @@ -314,7 +317,7 @@ static void initTimers() // initialize timers } timerList = new TimerList; #if defined(QT_THREAD_SUPPORT) - timerListMutex = new TQMutex(true); + tqt_timerListMutex = new TQMutex(true); #endif TQ_CHECK_PTR( timerList ); timerList->setAutoDelete( TRUE ); @@ -328,20 +331,25 @@ void cleanupTimers() timerList = 0; delete timerBitVec; timerBitVec = 0; -#if defined(QT_THREAD_SUPPORT) - delete timerListMutex; - timerListMutex = 0; -#endif } // Main timer functions for starting and killing timers int qStartTimer( int interval, TQObject *obj ) { +#if defined(QT_THREAD_SUPPORT) + if (tqt_timerListMutex) tqt_timerListMutex->lock(); +#endif if ( !timerList ) { // initialize timer data initTimers(); +#if defined(QT_THREAD_SUPPORT) + if (tqt_timerListMutex) tqt_timerListMutex->lock(); +#endif } int id = allocTimerId(); // get free timer id if ( (id <= 0) || (id > (int)timerBitVec->size()) || (!obj) ) { // cannot create timer +#if defined(QT_THREAD_SUPPORT) + if (tqt_timerListMutex) tqt_timerListMutex->unlock(); +#endif return 0; } timerBitVec->setBit( id-1 ); // set timer active @@ -355,18 +363,24 @@ int qStartTimer( int interval, TQObject *obj ) t->timeout = currentTime + t->interval; t->obj = obj; insertTimer( t ); // put timer in list +#if defined(QT_THREAD_SUPPORT) + if (tqt_timerListMutex) tqt_timerListMutex->unlock(); +#endif return id; } bool qKillTimer( int id ) { +#if defined(QT_THREAD_SUPPORT) + if (tqt_timerListMutex) tqt_timerListMutex->lock(); +#endif register TimerInfo *t; if ( (!timerList) || (id <= 0) || (id > (int)timerBitVec->size()) || (!timerBitVec->testBit( id-1 )) ) { - return FALSE; // not init'd or invalid timer - } #if defined(QT_THREAD_SUPPORT) - timerListMutex->lock(); + if (tqt_timerListMutex) tqt_timerListMutex->unlock(); #endif + return FALSE; // not init'd or invalid timer + } t = timerList->first(); while ( t && t->id != id ) { // find timer info in list t = timerList->next(); @@ -376,13 +390,13 @@ bool qKillTimer( int id ) timerBitVec->clearBit( id-1 ); // set timer inactive ret = timerList->remove(); #if defined(QT_THREAD_SUPPORT) - timerListMutex->unlock(); + if (tqt_timerListMutex) tqt_timerListMutex->unlock(); #endif return ret; } else { // id not found #if defined(QT_THREAD_SUPPORT) - timerListMutex->unlock(); + if (tqt_timerListMutex) tqt_timerListMutex->unlock(); #endif return FALSE; } @@ -390,13 +404,16 @@ bool qKillTimer( int id ) bool qKillTimer( TQObject *obj ) { +#if defined(QT_THREAD_SUPPORT) + if (tqt_timerListMutex) tqt_timerListMutex->lock(); +#endif register TimerInfo *t; if ( !timerList ) { // not initialized - return FALSE; - } #if defined(QT_THREAD_SUPPORT) - timerListMutex->lock(); + if (tqt_timerListMutex) tqt_timerListMutex->unlock(); #endif + return FALSE; + } t = timerList->first(); while ( t ) { // check all timers if ( t->obj == obj ) { // object found @@ -409,7 +426,7 @@ bool qKillTimer( TQObject *obj ) } } #if defined(QT_THREAD_SUPPORT) - timerListMutex->unlock(); + if (tqt_timerListMutex) tqt_timerListMutex->unlock(); #endif return TRUE; } @@ -615,12 +632,15 @@ int TQEventLoop::timeToWait() const int TQEventLoop::activateTimers() { +#if defined(QT_THREAD_SUPPORT) + if (tqt_timerListMutex) tqt_timerListMutex->lock(); +#endif if ( !timerList || !timerList->count() ) { // no timers - return 0; - } #if defined(QT_THREAD_SUPPORT) - timerListMutex->lock(); + if (tqt_timerListMutex) tqt_timerListMutex->unlock(); #endif + return 0; + } bool first = TRUE; timeval currentTime; int n_act = 0, maxCount = timerList->count(); @@ -663,7 +683,7 @@ int TQEventLoop::activateTimers() n_act++; } #if defined(QT_THREAD_SUPPORT) - timerListMutex->unlock(); + if (tqt_timerListMutex) tqt_timerListMutex->unlock(); #endif TQTimerEvent e( t->id ); #if defined(QT_THREAD_SUPPORT) @@ -678,14 +698,14 @@ int TQEventLoop::activateTimers() TQApplication::sendEvent( t->obj, &e ); // send event #endif // defined(QT_THREAD_SUPPORT) #if defined(QT_THREAD_SUPPORT) - timerListMutex->lock(); + if (tqt_timerListMutex) tqt_timerListMutex->lock(); #endif if ( timerList->findRef( begin ) == -1 ) { begin = 0; } } #if defined(QT_THREAD_SUPPORT) - timerListMutex->unlock(); + if (tqt_timerListMutex) tqt_timerListMutex->unlock(); #endif return n_act; } |