Fix incorrect thread termination handling when thread count is greater than two

This resolves Bug 1521
Make double free or delete of QString objects more obvious
pull/2/head
Timothy Pearson 12 years ago
parent 8ff73908ee
commit f2102e1f82

@ -3732,7 +3732,7 @@ void QApplication::removePostedEvent( QEvent * event )
void qThreadTerminationHandlerRecursive( QObject* object, QThread* originThread, QThread* destinationThread ) { void qThreadTerminationHandlerRecursive( QObject* object, QThread* originThread, QThread* destinationThread ) {
#ifdef QT_THREAD_SUPPORT #ifdef QT_THREAD_SUPPORT
QThread* objectThread = object->contextThreadObject(); QThread* objectThread = object->contextThreadObject();
if (objectThread && (objectThread != destinationThread)) { if (objectThread && (objectThread == originThread)) {
QThread::CleanupType cleanupType = objectThread->cleanupType(); QThread::CleanupType cleanupType = objectThread->cleanupType();
if (cleanupType == QThread::CleanupMergeObjects) { if (cleanupType == QThread::CleanupMergeObjects) {
object->moveToThread(destinationThread); object->moveToThread(destinationThread);

@ -1071,13 +1071,20 @@ QStringData::QStringData(QChar *u, uint l, uint m) : QShared(),
} }
QStringData::~QStringData() { QStringData::~QStringData() {
if ( unicode ) delete[] ((char*)unicode); if ( unicode ) {
delete[] ((char*)unicode);
}
if ( ascii && security_unpaged ) { if ( ascii && security_unpaged ) {
munlock(ascii, LINUX_MEMLOCK_LIMIT_BYTES); munlock(ascii, LINUX_MEMLOCK_LIMIT_BYTES);
} }
if ( ascii ) delete[] ascii; if ( ascii ) {
delete[] ascii;
}
#ifdef QT_THREAD_SUPPORT #ifdef QT_THREAD_SUPPORT
if ( mutex ) delete mutex; if ( mutex ) {
delete mutex;
mutex = NULL;
}
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT
} }
@ -1675,6 +1682,13 @@ QString::QString( QStringData* dd, bool /* dummy */ ) {
QString::~QString() QString::~QString()
{ {
#if defined(QT_CHECK_RANGE)
if (!d) {
qWarning( "QString::~QString: Double free or delete detected!" );
return;
}
#endif
#ifdef QT_THREAD_SUPPORT #ifdef QT_THREAD_SUPPORT
d->mutex->lock(); d->mutex->lock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT
@ -1684,6 +1698,7 @@ QString::~QString()
d->mutex->unlock(); d->mutex->unlock();
#endif // QT_THREAD_SUPPORT #endif // QT_THREAD_SUPPORT
d->deleteSelf(); d->deleteSelf();
d = NULL;
} }
else { else {
#ifdef QT_THREAD_SUPPORT #ifdef QT_THREAD_SUPPORT

@ -5181,11 +5181,13 @@ void QListView::keyPressEvent( QKeyEvent * e )
QListViewItem * QListView::itemAt( const QPoint & viewPos ) const QListViewItem * QListView::itemAt( const QPoint & viewPos ) const
{ {
if ( viewPos.x() > contentsWidth() - contentsX() ) if ( viewPos.x() > contentsWidth() - contentsX() ) {
return 0; return 0;
}
if ( !d->drawables || d->drawables->isEmpty() ) if ( !d->drawables || d->drawables->isEmpty() ) {
buildDrawableList(); buildDrawableList();
}
QListViewPrivate::DrawableItem * c = d->drawables->first(); QListViewPrivate::DrawableItem * c = d->drawables->first();
int g = viewPos.y() + contentsY(); int g = viewPos.y() + contentsY();

Loading…
Cancel
Save