From ce65fb47ed53d8ce2a00cdd399bbe8a28c4fb10d Mon Sep 17 00:00:00 2001 From: Duncan Cunningham Date: Wed, 31 Jul 2013 17:12:24 -0500 Subject: [PATCH] Fix crash in QQmlDebugService::objectForLocationInfo() Fixed crash in QQmlDebugService::objectForLocationInfo() where it was using QObject pointers in the object reference id hash table that had been deleted. Now objectForLocationInfo() checks if the QObject has been deleted and removes it from the object reference hash before trying to look up the filename, line number, and column number. Change-Id: Iba7be7c490e97a2e7685685b0c6e501cfe1e833e Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com> Reviewed-by: Aurindam Jana --- src/qml/debugger/qqmldebugservice.cpp | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/qml/debugger/qqmldebugservice.cpp b/src/qml/debugger/qqmldebugservice.cpp index f9a8090..f036dd9 100644 --- a/src/qml/debugger/qqmldebugservice.cpp +++ b/src/qml/debugger/qqmldebugservice.cpp @@ -215,25 +215,25 @@ QList QQmlDebugService::objectForLocationInfo(const QString &filename, { ObjectReferenceHash *hash = objectReferenceHash(); QList objects; - QHash::Iterator iter; - for (iter = hash->ids.begin(); iter != hash->ids.end(); ++iter) { - QQmlData *ddata = QQmlData::get(iter.value()); - if (!ddata || !ddata->outerContext) - continue; - //column number may be different due to qmlrewriter - if (QFileInfo(ddata->outerContext->urlString).fileName() == filename && - ddata->lineNumber == lineNumber && - ddata->columnNumber >= columnNumber) { - QHash::Iterator objIter = - hash->objects.find(*iter); - Q_ASSERT(objIter != hash->objects.end()); - - if (objIter->object == 0) { - hash->ids.erase(iter); - hash->objects.erase(objIter); - } else { - objects << *iter; + QHash::Iterator iter = hash->ids.begin(); + while (iter != hash->ids.end()) { + QHash::Iterator objIter = + hash->objects.find(*iter); + Q_ASSERT(objIter != hash->objects.end()); + + if (objIter->object == 0) { + iter = hash->ids.erase(iter); + hash->objects.erase(objIter); + } else { + QQmlData *ddata = QQmlData::get(iter.value()); + if (ddata && ddata->outerContext) { + if (QFileInfo(ddata->outerContext->urlString).fileName() == filename && + ddata->lineNumber == lineNumber && + ddata->columnNumber >= columnNumber) { + objects << *iter; + } } + ++iter; } } return objects; -- 2.7.4