diff options
Diffstat (limited to 'src/kernel/qobject.cpp')
-rw-r--r-- | src/kernel/qobject.cpp | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/src/kernel/qobject.cpp b/src/kernel/qobject.cpp index e931cdbe7..3ab2d9b97 100644 --- a/src/kernel/qobject.cpp +++ b/src/kernel/qobject.cpp @@ -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; } |