summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-06-10 13:20:17 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-06-10 13:20:17 -0500
commitf2102e1f829d216591a5f49819847c05383305ae (patch)
tree70f9fcdaafc62956e31c6ed585fbf4827f285436
parent8ff73908ee9670f5ce72613b65bf1b21b9544b96 (diff)
downloadqt3-f2102e1f829d216591a5f49819847c05383305ae.tar.gz
qt3-f2102e1f829d216591a5f49819847c05383305ae.zip
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
-rw-r--r--src/kernel/qapplication.cpp2
-rw-r--r--src/tools/qstring.cpp21
-rw-r--r--src/widgets/qlistview.cpp6
3 files changed, 23 insertions, 6 deletions
diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp
index e556e37..959f850 100644
--- a/src/kernel/qapplication.cpp
+++ b/src/kernel/qapplication.cpp
@@ -3732,7 +3732,7 @@ void QApplication::removePostedEvent( QEvent * event )
void qThreadTerminationHandlerRecursive( QObject* object, QThread* originThread, QThread* destinationThread ) {
#ifdef QT_THREAD_SUPPORT
QThread* objectThread = object->contextThreadObject();
- if (objectThread && (objectThread != destinationThread)) {
+ if (objectThread && (objectThread == originThread)) {
QThread::CleanupType cleanupType = objectThread->cleanupType();
if (cleanupType == QThread::CleanupMergeObjects) {
object->moveToThread(destinationThread);
diff --git a/src/tools/qstring.cpp b/src/tools/qstring.cpp
index 0630cd3..251637d 100644
--- a/src/tools/qstring.cpp
+++ b/src/tools/qstring.cpp
@@ -1071,13 +1071,20 @@ QStringData::QStringData(QChar *u, uint l, uint m) : QShared(),
}
QStringData::~QStringData() {
- if ( unicode ) delete[] ((char*)unicode);
+ if ( unicode ) {
+ delete[] ((char*)unicode);
+ }
if ( ascii && security_unpaged ) {
munlock(ascii, LINUX_MEMLOCK_LIMIT_BYTES);
}
- if ( ascii ) delete[] ascii;
+ if ( ascii ) {
+ delete[] ascii;
+ }
#ifdef QT_THREAD_SUPPORT
- if ( mutex ) delete mutex;
+ if ( mutex ) {
+ delete mutex;
+ mutex = NULL;
+ }
#endif // QT_THREAD_SUPPORT
}
@@ -1675,6 +1682,13 @@ QString::QString( QStringData* dd, bool /* dummy */ ) {
QString::~QString()
{
+#if defined(QT_CHECK_RANGE)
+ if (!d) {
+ qWarning( "QString::~QString: Double free or delete detected!" );
+ return;
+ }
+#endif
+
#ifdef QT_THREAD_SUPPORT
d->mutex->lock();
#endif // QT_THREAD_SUPPORT
@@ -1684,6 +1698,7 @@ QString::~QString()
d->mutex->unlock();
#endif // QT_THREAD_SUPPORT
d->deleteSelf();
+ d = NULL;
}
else {
#ifdef QT_THREAD_SUPPORT
diff --git a/src/widgets/qlistview.cpp b/src/widgets/qlistview.cpp
index 6f8ec29..6e2564c 100644
--- a/src/widgets/qlistview.cpp
+++ b/src/widgets/qlistview.cpp
@@ -5181,11 +5181,13 @@ void QListView::keyPressEvent( QKeyEvent * e )
QListViewItem * QListView::itemAt( const QPoint & viewPos ) const
{
- if ( viewPos.x() > contentsWidth() - contentsX() )
+ if ( viewPos.x() > contentsWidth() - contentsX() ) {
return 0;
+ }
- if ( !d->drawables || d->drawables->isEmpty() )
+ if ( !d->drawables || d->drawables->isEmpty() ) {
buildDrawableList();
+ }
QListViewPrivate::DrawableItem * c = d->drawables->first();
int g = viewPos.y() + contentsY();