forked from qt-creator/qt-creator
Fix Krazy warnings about values or keys iteration in QML code.
Change-Id: I78be5ec702d06ecc155842e9f092a13fc1cd6197 Reviewed-by: Aurindam Jana <aurindam.jana@digia.com> Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com>
This commit is contained in:
@@ -47,6 +47,17 @@ using namespace QmlDebug;
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
typedef QHash <QString, QmlRangeEventRelative *> EventHash;
|
||||
|
||||
static EventHash cloneEventHash(const EventHash &src)
|
||||
{
|
||||
EventHash result;
|
||||
const EventHash::ConstIterator cend = src.constEnd();
|
||||
for (EventHash::ConstIterator it = src.constBegin(); it != cend; ++it)
|
||||
result.insert(it.key(), new QmlRangeEventRelative(it.value()));
|
||||
return result;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
QmlRangeEventData::QmlRangeEventData()
|
||||
{
|
||||
@@ -64,9 +75,9 @@ QmlRangeEventData::QmlRangeEventData()
|
||||
|
||||
QmlRangeEventData::~QmlRangeEventData()
|
||||
{
|
||||
qDeleteAll(parentHash.values());
|
||||
qDeleteAll(parentHash);
|
||||
parentHash.clear();
|
||||
qDeleteAll(childrenHash.values());
|
||||
qDeleteAll(childrenHash);
|
||||
childrenHash.clear();
|
||||
}
|
||||
|
||||
@@ -90,17 +101,11 @@ QmlRangeEventData &QmlRangeEventData::operator=(const QmlRangeEventData &ref)
|
||||
eventId = ref.eventId;
|
||||
isBindingLoop = ref.isBindingLoop;
|
||||
|
||||
qDeleteAll(parentHash.values());
|
||||
parentHash.clear();
|
||||
foreach (const QString &key, ref.parentHash.keys()) {
|
||||
parentHash.insert(key, new QmlRangeEventRelative(ref.parentHash.value(key)));
|
||||
}
|
||||
qDeleteAll(parentHash);
|
||||
parentHash = cloneEventHash(ref.parentHash);
|
||||
|
||||
qDeleteAll(childrenHash.values());
|
||||
childrenHash.clear();
|
||||
foreach (const QString &key, ref.childrenHash.keys()) {
|
||||
childrenHash.insert(key, new QmlRangeEventRelative(ref.childrenHash.value(key)));
|
||||
}
|
||||
qDeleteAll(childrenHash);
|
||||
childrenHash = cloneEventHash(ref.childrenHash);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -263,7 +268,7 @@ QV8EventData *QmlProfilerDataModel::v8EventDescription(int eventId) const
|
||||
|
||||
void QmlProfilerDataModel::clear()
|
||||
{
|
||||
qDeleteAll(d->rangeEventDictionary.values());
|
||||
qDeleteAll(d->rangeEventDictionary);
|
||||
d->rangeEventDictionary.clear();
|
||||
|
||||
d->endInstanceList.clear();
|
||||
@@ -1289,8 +1294,8 @@ void QmlProfilerDataModel::QmlProfilerDataModelPrivate::clearQmlRootEvent()
|
||||
qmlRootEvent.medianTime = 0;
|
||||
qmlRootEvent.eventId = -1;
|
||||
|
||||
qDeleteAll(qmlRootEvent.parentHash.values());
|
||||
qDeleteAll(qmlRootEvent.childrenHash.values());
|
||||
qDeleteAll(qmlRootEvent.parentHash);
|
||||
qDeleteAll(qmlRootEvent.childrenHash);
|
||||
qmlRootEvent.parentHash.clear();
|
||||
qmlRootEvent.childrenHash.clear();
|
||||
}
|
||||
|
||||
@@ -42,6 +42,17 @@ QT_END_NAMESPACE
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
typedef QHash <QString, QV8EventSub *> EventHash;
|
||||
|
||||
static EventHash cloneEventHash(const EventHash &src)
|
||||
{
|
||||
EventHash result;
|
||||
const EventHash::ConstIterator cend = src.constEnd();
|
||||
for (EventHash::ConstIterator it = src.constBegin(); it != cend; ++it)
|
||||
result.insert(it.key(), new QV8EventSub(it.value()));
|
||||
return result;
|
||||
}
|
||||
|
||||
QV8EventData &QV8EventData::operator=(const QV8EventData &ref)
|
||||
{
|
||||
if (this == &ref)
|
||||
@@ -58,17 +69,12 @@ QV8EventData &QV8EventData::operator=(const QV8EventData &ref)
|
||||
selfPercent = ref.selfPercent;
|
||||
eventId = ref.eventId;
|
||||
|
||||
qDeleteAll(parentHash.values());
|
||||
parentHash.clear();
|
||||
foreach (const QString &key, ref.parentHash.keys()) {
|
||||
parentHash.insert(key, new QV8EventSub(ref.parentHash.value(key)));
|
||||
}
|
||||
qDeleteAll(parentHash);
|
||||
parentHash = cloneEventHash(ref.parentHash);
|
||||
|
||||
qDeleteAll(childrenHash);
|
||||
childrenHash = cloneEventHash(ref.childrenHash);
|
||||
|
||||
qDeleteAll(childrenHash.values());
|
||||
childrenHash.clear();
|
||||
foreach (const QString &key, ref.childrenHash.keys()) {
|
||||
childrenHash.insert(key, new QV8EventSub(ref.childrenHash.value(key)));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -440,8 +446,12 @@ void QV8ProfilerDataModel::load(QXmlStreamReader &stream)
|
||||
d->v8MeasuredTime = cumulatedV8Time;
|
||||
|
||||
// find v8events' children and parents
|
||||
foreach (int parentIndex, childrenIndexes.keys()) {
|
||||
QStringList childrenStrings = childrenIndexes.value(parentIndex).split(QLatin1String(","));
|
||||
typedef QHash <int, QString>::ConstIterator ChildIndexConstIt;
|
||||
|
||||
const ChildIndexConstIt icend = childrenIndexes.constEnd();
|
||||
for (ChildIndexConstIt it = childrenIndexes.constBegin(); it != icend; ++it) {
|
||||
const int parentIndex = it.key();
|
||||
const QStringList childrenStrings = it.value().split(QLatin1Char(','));
|
||||
QStringList childrenTimesStrings = childrenTimes.value(parentIndex).split(QLatin1String(", "));
|
||||
QStringList parentTimesStrings = parentTimes.value(parentIndex).split(QLatin1String(", "));
|
||||
for (int ndx = 0; ndx < childrenStrings.count(); ndx++) {
|
||||
|
||||
Reference in New Issue
Block a user