Fix possible SEGV if the sender object list was null and thread support enabled

Commit manually cherry-picked from 8e653076.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
r14.1.x
Michele Calgaro 3 months ago
parent 08ac5cce69
commit b6eef6a49e
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -1101,20 +1101,20 @@ bool TQObject::event( TQEvent *e )
|| (d->ownThread == TQThread::currentThreadObject())) || (d->ownThread == TQThread::currentThreadObject()))
#endif // TQT_THREAD_SUPPORT #endif // TQT_THREAD_SUPPORT
{ {
TQSenderObjectList* sol; TQObject *oldSender = nullptr;
TQObject* oldSender = 0; TQSenderObjectList *sol = senderObjects;
sol = senderObjects; if ( sol )
{
#ifdef TQT_THREAD_SUPPORT #ifdef TQT_THREAD_SUPPORT
sol->listMutex->lock(); sol->listMutex->lock();
#endif // TQT_THREAD_SUPPORT #endif // TQT_THREAD_SUPPORT
if ( sol ) {
oldSender = sol->currentSender; oldSender = sol->currentSender;
sol->ref(); sol->ref();
sol->currentSender = metaEvent->sender(); sol->currentSender = metaEvent->sender();
}
#ifdef TQT_THREAD_SUPPORT #ifdef TQT_THREAD_SUPPORT
sol->listMutex->unlock(); sol->listMutex->unlock();
#endif // TQT_THREAD_SUPPORT #endif // TQT_THREAD_SUPPORT
}
TQUObject *o = metaEvent->data(); TQUObject *o = metaEvent->data();
if (metaEvent->type() == TQMetaCallEvent::MetaCallEmit) { if (metaEvent->type() == TQMetaCallEvent::MetaCallEmit) {
tqt_emit( metaEvent->id(), o ); tqt_emit( metaEvent->id(), o );
@ -1122,25 +1122,31 @@ bool TQObject::event( TQEvent *e )
if (metaEvent->type() == TQMetaCallEvent::MetaCallInvoke) { if (metaEvent->type() == TQMetaCallEvent::MetaCallInvoke) {
tqt_invoke( metaEvent->id(), o ); tqt_invoke( metaEvent->id(), o );
} }
if ( sol )
{
#ifdef TQT_THREAD_SUPPORT #ifdef TQT_THREAD_SUPPORT
sol->listMutex->lock(); sol->listMutex->lock();
#endif // TQT_THREAD_SUPPORT #endif // TQT_THREAD_SUPPORT
if (sol ) {
sol->currentSender = oldSender; sol->currentSender = oldSender;
if ( sol->deref() ) { if ( sol->deref() )
{
#ifdef TQT_THREAD_SUPPORT #ifdef TQT_THREAD_SUPPORT
sol->listMutex->unlock(); sol->listMutex->unlock();
#endif // TQT_THREAD_SUPPORT #endif // TQT_THREAD_SUPPORT
delete sol; delete sol;
sol = NULL; sol = nullptr;
} }
} }
#ifdef TQT_THREAD_SUPPORT #ifdef TQT_THREAD_SUPPORT
if (sol) sol->listMutex->unlock(); if (sol)
{
sol->listMutex->unlock();
}
#endif // TQT_THREAD_SUPPORT #endif // TQT_THREAD_SUPPORT
} }
#ifdef TQT_THREAD_SUPPORT #ifdef TQT_THREAD_SUPPORT
else { else
{
tqWarning("TQObject: Ignoring metacall event from non-owning thread"); tqWarning("TQObject: Ignoring metacall event from non-owning thread");
} }
#endif // TQT_THREAD_SUPPORT #endif // TQT_THREAD_SUPPORT

Loading…
Cancel
Save