summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2015-07-19 21:49:36 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2015-08-26 23:11:14 +0900
commita6e1bf7da559b25ac2bda3654661e95a41e367c3 (patch)
treef11cc9712fa17dc4019cf371c7d5117b1fb0a89e /src
parentfdcad492bdeea7f6938b15f10a225480e2e00fc6 (diff)
downloadtqt3-a6e1bf7da559b25ac2bda3654661e95a41e367c3.tar.gz
tqt3-a6e1bf7da559b25ac2bda3654661e95a41e367c3.zip
Added safety harness for currentThreadObject() usage.
currentThreadObject() returns a null pointer if the current thread was not started using the TQThread API. This relates to bug 1748. (cherry picked from commit caab7b355740dd9661046c1bf73e1add9de9d045) Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'src')
-rw-r--r--src/kernel/qeventloop_unix_glib.cpp8
-rw-r--r--src/kernel/qobject.cpp24
2 files changed, 25 insertions, 7 deletions
diff --git a/src/kernel/qeventloop_unix_glib.cpp b/src/kernel/qeventloop_unix_glib.cpp
index 795dc9ba8..ceacd81b8 100644
--- a/src/kernel/qeventloop_unix_glib.cpp
+++ b/src/kernel/qeventloop_unix_glib.cpp
@@ -688,7 +688,9 @@ int TQEventLoop::activateTimers()
TQTimerEvent e( t->id );
#if defined(QT_THREAD_SUPPORT)
// Be careful...the current thread may not be the target object's thread!
- if ((!t->obj) || (TQThread::currentThreadObject()->threadPostedEventsDisabled()) || (t->obj && (t->obj->contextThreadObject() == TQThread::currentThreadObject()))) {
+ if ((!t->obj) ||
+ (TQThread::currentThreadObject() && TQThread::currentThreadObject()->threadPostedEventsDisabled()) ||
+ (t->obj && t->obj->contextThreadObject() == TQThread::currentThreadObject())) {
TQApplication::sendEvent( t->obj, &e ); // send event
}
else {
@@ -731,7 +733,9 @@ int TQEventLoop::activateSocketNotifiers()
sn->pending = FALSE;
#if defined(QT_THREAD_SUPPORT)
// Be careful...the current thread may not be the target object's thread!
- if ((!sn->obj) || (TQThread::currentThreadObject()->threadPostedEventsDisabled()) || (sn->obj && (sn->obj->contextThreadObject() == TQThread::currentThreadObject()))) {
+ if ((!sn->obj) ||
+ (TQThread::currentThreadObject() && TQThread::currentThreadObject()->threadPostedEventsDisabled()) ||
+ (sn->obj && sn->obj->contextThreadObject() == TQThread::currentThreadObject())) {
TQApplication::sendEvent( sn->obj, &event ); // send event
}
else {
diff --git a/src/kernel/qobject.cpp b/src/kernel/qobject.cpp
index e90e2bd9b..665aead21 100644
--- a/src/kernel/qobject.cpp
+++ b/src/kernel/qobject.cpp
@@ -203,9 +203,10 @@ void TQObject::moveToThread(TQThread *targetThread)
}
TQThread *objectThread = contextThreadObject();
+ // NOTE currentThread could be NULL if the current thread was not started using the TQThread API
TQThread *currentThread = TQThread::currentThreadObject();
- if (objectThread != currentThread) {
+ if (currentThread && objectThread != currentThread) {
#if defined(QT_DEBUG)
tqWarning( "TQObject::moveToThread: Current thread is not the object's thread" );
#endif
@@ -2760,6 +2761,7 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
}
#endif
+ // NOTE currentThread could be NULL if the current thread was not started using the TQThread API
const TQThread *currentThread = TQThread::currentThreadObject();
TQObject *object;
@@ -2779,7 +2781,10 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
sol->currentSender = this;
}
if ( c->memberType() == TQSIGNAL_CODE ) {
- if ((d->disableThreadPostedEvents) || (object->d->disableThreadPostedEvents) || (currentThread->threadPostedEventsDisabled()) || (object->d->ownThread == currentThread)) {
+ if ((d->disableThreadPostedEvents) ||
+ (object->d->disableThreadPostedEvents) ||
+ (currentThread && currentThread->threadPostedEventsDisabled()) ||
+ (currentThread && object->d->ownThread == currentThread)) {
#ifdef QT_THREAD_SUPPORT
sol->listMutex->unlock();
#endif // QT_THREAD_SUPPORT
@@ -2798,7 +2803,10 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
}
}
else {
- if ((d->disableThreadPostedEvents) || (object->d->disableThreadPostedEvents) || (currentThread->threadPostedEventsDisabled()) || (object->d->ownThread == currentThread)) {
+ if ((d->disableThreadPostedEvents) ||
+ (object->d->disableThreadPostedEvents) ||
+ (currentThread && currentThread->threadPostedEventsDisabled()) ||
+ (currentThread && object->d->ownThread == currentThread)) {
#ifdef QT_THREAD_SUPPORT
sol->listMutex->unlock();
#endif // QT_THREAD_SUPPORT
@@ -2846,7 +2854,10 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
sol->currentSender = this;
}
if ( c->memberType() == TQSIGNAL_CODE ) {
- if ((d->disableThreadPostedEvents) || (object->d->disableThreadPostedEvents) || (currentThread->threadPostedEventsDisabled()) || (object->d->ownThread == currentThread)) {
+ if ((d->disableThreadPostedEvents) ||
+ (object->d->disableThreadPostedEvents) ||
+ (currentThread && currentThread->threadPostedEventsDisabled()) ||
+ (currentThread && object->d->ownThread == currentThread)) {
#ifdef QT_THREAD_SUPPORT
sol->listMutex->unlock();
#endif // QT_THREAD_SUPPORT
@@ -2865,7 +2876,10 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
}
}
else {
- if ((d->disableThreadPostedEvents) || (object->d->disableThreadPostedEvents) || (currentThread->threadPostedEventsDisabled()) || (object->d->ownThread == currentThread)) {
+ if ((d->disableThreadPostedEvents) ||
+ (object->d->disableThreadPostedEvents) ||
+ (currentThread && currentThread->threadPostedEventsDisabled()) ||
+ (currentThread && object->d->ownThread == currentThread)) {
#ifdef QT_THREAD_SUPPORT
sol->listMutex->unlock();
#endif // QT_THREAD_SUPPORT