summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Golubev <fatzer2@gmail.com>2024-03-11 13:47:16 +0300
committerAlexander Golubev <fatzer2@gmail.com>2024-03-11 13:47:16 +0300
commit75efd1af6b8d1e3acaa338db848336090c35893b (patch)
tree67dfa6a1b0d9c00937de47eec5c85db6b8c8899a
parentcbdf33337892590c7f81ce37d8f67894912753af (diff)
downloadtqt3-feat/naive-dedup.tar.gz
tqt3-feat/naive-dedup.zip
Deduplicate code in TQObject::activate_signal()feat/naive-dedup
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
-rw-r--r--src/kernel/qobject.cpp127
1 files changed, 28 insertions, 99 deletions
diff --git a/src/kernel/qobject.cpp b/src/kernel/qobject.cpp
index 3ab2d9b97..c13ed1085 100644
--- a/src/kernel/qobject.cpp
+++ b/src/kernel/qobject.cpp
@@ -2789,12 +2789,17 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
TQSenderObjectList* sol;
TQObject* oldSender = 0;
TQConnection *c;
- if ( clist->count() == 1 ) { // save iterator
- c = clist->first();
+ TQConnection *cd = 0;
+ TQConnectionListIt it(*clist);
+ while ( (c=it.current()) ) {
+ ++it;
+ if ( c == cd )
+ continue;
+ cd = c;
object = c->object();
sol = object->senderObjects;
#ifdef TQT_THREAD_SUPPORT
- sol->listMutex->lock();
+ sol->listMutex->lock();
#endif // TQT_THREAD_SUPPORT
if ( sol ) {
oldSender = sol->currentSender;
@@ -2802,13 +2807,11 @@ 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
+ if ((d->disableThreadPostedEvents) ||
+ (object->d->disableThreadPostedEvents) ||
+ (currentThread && currentThread->threadPostedEventsDisabled()) ||
+ (currentThread && object->d->ownThread == currentThread)) {
sol->listMutex->unlock();
object->tqt_emit( c->member(), o );
sol->listMutex->lock();
@@ -2816,21 +2819,21 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
else {
if (object->d->ownThread && !object->d->ownThread->finished()) {
#ifdef QT_DEBUG
- tqDebug("TQObject::activate_signal: Emitting cross-thread signal from object %p (member %d receiver %p) (1)\n", this, c->member(), object);
+ tqDebug("TQObject::activate_signal: Emitting cross-thread signal from object %p (member %d receiver %p)\n", this, c->member(), object);
#endif // QT_DEBUG
TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallEmit));
}
}
-#endif // !defined(TQT_THREAD_SUPPORT)
+#else // !TQT_THREAD_SUPPORT
+ object->tqt_emit( c->member(), o );
+#endif // 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
+ if ((d->disableThreadPostedEvents) ||
+ (object->d->disableThreadPostedEvents) ||
+ (currentThread && currentThread->threadPostedEventsDisabled()) ||
+ (currentThread && object->d->ownThread == currentThread)) {
sol->listMutex->unlock();
object->tqt_invoke( c->member(), o );
sol->listMutex->lock();
@@ -2838,18 +2841,20 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
else {
if (object->d->ownThread && !object->d->ownThread->finished()) {
#ifdef QT_DEBUG
- tqDebug("TQObject::activate_signal: Invoking cross-thread method from object %p (member %d receiver %p) (1)\n", this, c->member(), object);
+ tqDebug("TQObject::activate_signal: Invoking cross-thread method from object %p (member %d receiver %p)\n", this, c->member(), object);
#endif // QT_DEBUG
TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallInvoke));
}
}
-#endif // !defined(TQT_THREAD_SUPPORT)
+#else // !TQT_THREAD_SUPPORT
+ object->tqt_invoke( c->member(), o );
+#endif // TQT_THREAD_SUPPORT
}
- if ( sol ) {
+ if (sol ) {
sol->currentSender = oldSender;
if ( sol->deref() ) {
#ifdef TQT_THREAD_SUPPORT
- sol->listMutex->unlock();
+ sol->listMutex->unlock();
#endif // TQT_THREAD_SUPPORT
delete sol;
sol = NULL;
@@ -2858,82 +2863,6 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
#ifdef TQT_THREAD_SUPPORT
if (sol) sol->listMutex->unlock();
#endif // TQT_THREAD_SUPPORT
- } else {
- TQConnection *cd = 0;
- TQConnectionListIt it(*clist);
- while ( (c=it.current()) ) {
- ++it;
- if ( c == cd )
- continue;
- cd = c;
- object = c->object();
- sol = object->senderObjects;
-#ifdef TQT_THREAD_SUPPORT
- sol->listMutex->lock();
-#endif // TQT_THREAD_SUPPORT
- if ( sol ) {
- oldSender = sol->currentSender;
- sol->ref();
- 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)) {
- sol->listMutex->unlock();
- object->tqt_emit( c->member(), o );
- sol->listMutex->lock();
- }
- else {
- if (object->d->ownThread && !object->d->ownThread->finished()) {
-#ifdef QT_DEBUG
- tqDebug("TQObject::activate_signal: Emitting cross-thread signal from object %p (member %d receiver %p) (2)\n", this, c->member(), object);
-#endif // QT_DEBUG
- 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)) {
- sol->listMutex->unlock();
- object->tqt_invoke( c->member(), o );
- sol->listMutex->lock();
- }
- else {
- if (object->d->ownThread && !object->d->ownThread->finished()) {
-#ifdef QT_DEBUG
- tqDebug("TQObject::activate_signal: Invoking cross-thread method from object %p (member %d receiver %p) (2)\n", this, c->member(), object);
-#endif // QT_DEBUG
- 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;
- }
- }
-#ifdef TQT_THREAD_SUPPORT
- if (sol) sol->listMutex->unlock();
-#endif // TQT_THREAD_SUPPORT
- }
}
}