Fix compilation with -no-thread

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
(cherry picked from commit 4100c9e29f)
r14.1.x
Alexander Golubev 9 months ago committed by Michele Calgaro
parent 9d1f80158e
commit d643d19c96
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -572,8 +572,6 @@ private:
static TQCoreApplicationThread tqt_main_thread;
static TQThread *mainThread() { return &tqt_main_thread; }
#else
static TQThread* mainThread() { return TQThread::currentThread(); }
#endif
// Definitions for posted events
@ -3033,6 +3031,7 @@ int TQApplication::exec()
*/
void TQApplication::exit( int retcode )
{
#ifdef TQT_THREAD_SUPPORT
TQThread* thread = tqApp->guiThread();
if (thread) {
if (thread->d) {
@ -3041,6 +3040,9 @@ void TQApplication::exit( int retcode )
}
}
}
#else
tqApp->eventLoop()->exit( retcode );
#endif // TQT_THREAD_SUPPORT
}
/*!
@ -3540,12 +3542,18 @@ void TQApplication::sendPostedEvents( TQObject *receiver, int event_type )
TQPostEvent *pe;
while ( (pe=it.current()) != 0 ) {
++it;
Q_ASSERT(pe->receiver);
if ( pe->event // hasn't been sent yet
&& ( receiver == 0 // we send to all receivers
|| receiver == pe->receiver ) // we send to THAT receiver
&& ( event_type == 0 // we send all types
|| event_type == pe->event->type() ) // we send THAT type
&& ( (!pe->receiver) || ((pe->receiver) && (!pe->receiver->wasDeleted) && (pe->receiver->contextThreadObject() == TQThread::currentThreadObject())) ) ) { // only send if active thread is receiver object owning thread
&& ( !pe->receiver->wasDeleted ) // don't send if receiver was deleted
#ifdef TQT_THREAD_SUPPORT
// only send if active thread is receiver object owning thread
&& ( pe->receiver->contextThreadObject() == TQThread::currentThreadObject() )
#endif
) {
// first, we diddle the event so that we can deliver
// it, and that noone will try to touch it later.
pe->event->posted = FALSE;
@ -3796,8 +3804,8 @@ void TQApplication::removePostedEvent( TQEvent * event )
}
}
void tqThreadTerminationHandlerRecursive( TQObject* object, TQThread* originThread, TQThread* destinationThread ) {
#ifdef TQT_THREAD_SUPPORT
static void tqThreadTerminationHandlerRecursive( TQObject* object, TQThread* originThread, TQThread* destinationThread ) {
TQThread* objectThread = object->contextThreadObject();
if (objectThread && (objectThread == originThread)) {
TQThread::CleanupType cleanupType = objectThread->cleanupType();
@ -3822,7 +3830,6 @@ void tqThreadTerminationHandlerRecursive( TQObject* object, TQThread* originThre
for ( childObject = children.first(); childObject; childObject = children.next() ) {
tqThreadTerminationHandlerRecursive(childObject, originThread, destinationThread);
}
#endif // TQT_THREAD_SUPPORT
}
/*!\internal
@ -3831,15 +3838,14 @@ void tqThreadTerminationHandlerRecursive( TQObject* object, TQThread* originThre
for thread destruction.
*/
void TQApplication::threadTerminationHandler( TQThread *originThread ) {
#ifdef TQT_THREAD_SUPPORT
TQMutexLocker locker( tqt_mutex );
TQThread* destinationThread = guiThread();
const TQObjectList* objects = TQObject::objectTrees();
for ( TQObjectListIt objectit( *objects ) ; *objectit; ++objectit ) {
tqThreadTerminationHandlerRecursive((*objectit), originThread, destinationThread);
}
#endif // TQT_THREAD_SUPPORT
}
#endif // TQT_THREAD_SUPPORT
/*!\internal

@ -107,9 +107,11 @@ TQEventLoop::TQEventLoop( TQObject *parent, const char *name )
#if defined(QT_CHECK_STATE)
if ( TQApplication::currentEventLoop() )
tqFatal( "TQEventLoop: there must be only one event loop object per thread. \nIf this is supposed to be the main GUI event loop, construct it before TQApplication." );
#ifdef TQT_THREAD_SUPPORT
if (!TQThread::currentThreadObject()) {
tqFatal( "TQEventLoop: this object can only be used in threads constructed via TQThread." );
}
#endif // TQT_THREAD_SUPPORT
#endif // QT_CHECK_STATE
d = new TQEventLoopPrivate;

@ -97,8 +97,10 @@ class TQObjectPrivate {
public:
#ifndef TQT_NO_USERDATA
TQObjectPrivate( uint s ) : TQPtrVector<TQObjectUserData>(s) {
#ifdef TQT_THREAD_SUPPORT
ownThread = NULL;
disableThreadPostedEvents = false;
#endif
setAutoDelete( TRUE );
controlElementData = NULL;
controlElementDataPrivate = NULL;
@ -108,10 +110,12 @@ public:
delete controlElementDataPrivate;
}
#endif
#ifdef TQT_THREAD_SUPPORT
TQThread* ownThread;
TQMutex* senderObjectListMutex;
TQMutex* childObjectListMutex;
bool disableThreadPostedEvents;
#endif
TQStyleControlElementData* controlElementData;
TQStyleControlElementDataPrivate* controlElementDataPrivate;
};
@ -240,7 +244,7 @@ void TQObject::disableThreadPostedEvents(bool disable) {
d->disableThreadPostedEvents = disable;
}
#endif
#endif // defined(TQT_THREAD_SUPPORT)
class TQSenderObjectList : public TQObjectList, public TQShared
{
@ -250,15 +254,21 @@ class TQSenderObjectList : public TQObjectList, public TQShared
public:
TQObject *currentSender;
#ifdef TQT_THREAD_SUPPORT
TQMutex *listMutex;
#endif
};
TQSenderObjectList::TQSenderObjectList() : currentSender( 0 ) {
#ifdef TQT_THREAD_SUPPORT
listMutex = new TQMutex( TRUE );
#endif
}
TQSenderObjectList::~TQSenderObjectList() {
#ifdef TQT_THREAD_SUPPORT
delete listMutex;
#endif
}
class TQ_EXPORT TQMetaCallEvent : public TQEvent
@ -667,10 +677,11 @@ TQObject::TQObject( TQObject *parent, const char *name )
d = new TQObjectPrivate(0);
}
#ifdef TQT_THREAD_SUPPORT
d->ownThread = TQThread::currentThreadObject();
d->senderObjectListMutex = new TQMutex( TRUE );
d->childObjectListMutex = new TQMutex( TRUE );
#endif
if ( !metaObj ) { // will create object dict
(void) staticMetaObject();
}
@ -1075,7 +1086,11 @@ bool TQObject::event( TQEvent *e )
{
TQMetaCallEvent* metaEvent = dynamic_cast<TQMetaCallEvent*>(e);
if (metaEvent) {
if ((d->disableThreadPostedEvents) || (d->ownThread == TQThread::currentThreadObject())) {
#ifdef TQT_THREAD_SUPPORT
if ((d->disableThreadPostedEvents)
|| (d->ownThread == TQThread::currentThreadObject()))
#endif // TQT_THREAD_SUPPORT
{
TQSenderObjectList* sol;
TQObject* oldSender = 0;
sol = senderObjects;
@ -1103,7 +1118,9 @@ bool TQObject::event( TQEvent *e )
if (sol ) {
sol->currentSender = oldSender;
if ( sol->deref() ) {
#ifdef TQT_THREAD_SUPPORT
sol->listMutex->unlock();
#endif // TQT_THREAD_SUPPORT
delete sol;
sol = NULL;
}
@ -1112,9 +1129,11 @@ bool TQObject::event( TQEvent *e )
if (sol) sol->listMutex->unlock();
#endif // TQT_THREAD_SUPPORT
}
#ifdef TQT_THREAD_SUPPORT
else {
tqWarning("TQObject: Ignoring metacall event from non-owning thread");
}
#endif // TQT_THREAD_SUPPORT
destroyDeepCopiedTQUObjectArray(metaEvent->data());
}
}
@ -2761,8 +2780,10 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
}
#endif
#ifdef TQT_THREAD_SUPPORT
// NOTE currentThread could be NULL if the current thread was not started using the TQThread API
const TQThread *currentThread = TQThread::currentThreadObject();
#endif // TQT_THREAD_SUPPORT
TQObject *object;
TQSenderObjectList* sol;
@ -2781,17 +2802,16 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
sol->currentSender = this;
}
if ( c->memberType() == TQ_SIGNAL_CODE ) {
#if !defined(TQT_THREAD_SUPPORT)
object->tqt_emit( c->member(), o );
#else // defined(TQT_THREAD_SUPPORT)
if ((d->disableThreadPostedEvents) ||
(object->d->disableThreadPostedEvents) ||
(currentThread && currentThread->threadPostedEventsDisabled()) ||
(currentThread && object->d->ownThread == currentThread)) {
#ifdef TQT_THREAD_SUPPORT
sol->listMutex->unlock();
#endif // TQT_THREAD_SUPPORT
object->tqt_emit( c->member(), o );
#ifdef TQT_THREAD_SUPPORT
sol->listMutex->lock();
#endif // TQT_THREAD_SUPPORT
}
else {
if (object->d->ownThread && !object->d->ownThread->finished()) {
@ -2801,19 +2821,19 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallEmit));
}
}
#endif // !defined(TQT_THREAD_SUPPORT)
}
else {
#if !defined(TQT_THREAD_SUPPORT)
object->tqt_invoke( c->member(), o );
#else // defined(TQT_THREAD_SUPPORT)
if ((d->disableThreadPostedEvents) ||
(object->d->disableThreadPostedEvents) ||
(currentThread && currentThread->threadPostedEventsDisabled()) ||
(currentThread && object->d->ownThread == currentThread)) {
#ifdef TQT_THREAD_SUPPORT
sol->listMutex->unlock();
#endif // TQT_THREAD_SUPPORT
object->tqt_invoke( c->member(), o );
#ifdef TQT_THREAD_SUPPORT
sol->listMutex->lock();
#endif // TQT_THREAD_SUPPORT
}
else {
if (object->d->ownThread && !object->d->ownThread->finished()) {
@ -2823,11 +2843,14 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallInvoke));
}
}
#endif // !defined(TQT_THREAD_SUPPORT)
}
if ( sol ) {
sol->currentSender = oldSender;
if ( sol->deref() ) {
#ifdef TQT_THREAD_SUPPORT
sol->listMutex->unlock();
#endif // TQT_THREAD_SUPPORT
delete sol;
sol = NULL;
}
@ -2854,17 +2877,16 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
sol->currentSender = this;
}
if ( c->memberType() == TQ_SIGNAL_CODE ) {
#if !defined(TQT_THREAD_SUPPORT)
object->tqt_emit( c->member(), o );
#else // defined(TQT_THREAD_SUPPORT)
if ((d->disableThreadPostedEvents) ||
(object->d->disableThreadPostedEvents) ||
(currentThread && currentThread->threadPostedEventsDisabled()) ||
(currentThread && object->d->ownThread == currentThread)) {
#ifdef TQT_THREAD_SUPPORT
sol->listMutex->unlock();
#endif // TQT_THREAD_SUPPORT
object->tqt_emit( c->member(), o );
#ifdef TQT_THREAD_SUPPORT
sol->listMutex->lock();
#endif // TQT_THREAD_SUPPORT
}
else {
if (object->d->ownThread && !object->d->ownThread->finished()) {
@ -2874,19 +2896,19 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallEmit));
}
}
#endif // !defined(TQT_THREAD_SUPPORT)
}
else {
#if !defined(TQT_THREAD_SUPPORT)
object->tqt_invoke( c->member(), o );
#else // defined(TQT_THREAD_SUPPORT)
if ((d->disableThreadPostedEvents) ||
(object->d->disableThreadPostedEvents) ||
(currentThread && currentThread->threadPostedEventsDisabled()) ||
(currentThread && object->d->ownThread == currentThread)) {
#ifdef TQT_THREAD_SUPPORT
sol->listMutex->unlock();
#endif // TQT_THREAD_SUPPORT
object->tqt_invoke( c->member(), o );
#ifdef TQT_THREAD_SUPPORT
sol->listMutex->lock();
#endif // TQT_THREAD_SUPPORT
}
else {
if (object->d->ownThread && !object->d->ownThread->finished()) {
@ -2896,11 +2918,14 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallInvoke));
}
}
#endif // !defined(TQT_THREAD_SUPPORT)
}
if (sol ) {
sol->currentSender = oldSender;
if ( sol->deref() ) {
#ifdef TQT_THREAD_SUPPORT
sol->listMutex->unlock();
#endif // TQT_THREAD_SUPPORT
delete sol;
sol = NULL;
}

@ -1,2 +1,3 @@
TEMPLATE = subdirs
SUBDIRS = t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15
SUBDIRS = t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
thread:SUBDIRS += t15

Loading…
Cancel
Save