Commit 225c21a0 authored by Friedemann Kleint's avatar Friedemann Kleint

Fix Krazy warnings about values or keys iteration in QML code.

Change-Id: I78be5ec702d06ecc155842e9f092a13fc1cd6197
Reviewed-by: default avatarAurindam Jana <aurindam.jana@digia.com>
Reviewed-by: default avatarChristiaan Janssen <christiaan.janssen@digia.com>
parent efe98de8
......@@ -165,10 +165,12 @@ QByteArray convertToId(const QMetaObject *mo)
QSet<const QMetaObject *> collectReachableMetaObjects(const QList<QDeclarativeType *> &skip = QList<QDeclarativeType *>())
{
typedef QHash<QByteArray, QSet<QByteArray> > ExtensionHash;
QSet<const QMetaObject *> metas;
metas.insert(FriendlyQObject::qtMeta());
QHash<QByteArray, QSet<QByteArray> > extensions;
ExtensionHash extensions;
foreach (const QDeclarativeType *ty, QDeclarativeMetaType::qmlTypes()) {
qmlTypesByCppName[ty->metaObject()->className()].insert(ty);
if (ty->isExtendedType()) {
......@@ -181,10 +183,12 @@ QSet<const QMetaObject *> collectReachableMetaObjects(const QList<QDeclarativeTy
// For each export of a base object there can be a single extension object overriding it.
// Example: QDeclarativeGraphicsWidget overrides the QtQuick/QGraphicsWidget export
// of QGraphicsWidget.
foreach (const QByteArray &baseCpp, extensions.keys()) {
const ExtensionHash::ConstIterator cend = extensions.constEnd();
for (ExtensionHash::ConstIterator it = extensions.constBegin(); it != cend; ++it) {
const QByteArray &baseCpp = it.key();
QSet<const QDeclarativeType *> baseExports = qmlTypesByCppName.value(baseCpp);
const QSet<QByteArray> extensionCppNames = extensions.value(baseCpp);
const QSet<QByteArray> &extensionCppNames = it.value();
foreach (const QByteArray &extensionCppName, extensionCppNames) {
const QSet<const QDeclarativeType *> extensionExports = qmlTypesByCppName.value(extensionCppName);
......
......@@ -503,8 +503,8 @@ void QmlInspectorAdapter::selectObject(const ObjectReference &obj,
void QmlInspectorAdapter::deletePreviews()
{
foreach (const QString &key, m_textPreviews.keys())
delete m_textPreviews.take(key);
qDeleteAll(m_textPreviews);
m_textPreviews.clear();
}
void QmlInspectorAdapter::enableTools(const bool enable)
......
......@@ -1390,13 +1390,7 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data)
BreakHandler *handler = d->engine->breakHandler();
foreach (int v8Id, v8BreakpointIds) {
BreakpointModelId internalId;
foreach (const BreakpointModelId &id, d->breakpoints.keys()) {
if (d->breakpoints.value(id) == v8Id) {
internalId = id;
break;
}
}
const BreakpointModelId internalId = d->breakpoints.key(v8Id);
if (internalId.isValid()) {
const BreakpointParameters &params = handler->breakpointData(internalId);
......@@ -1426,19 +1420,18 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data)
//Update breakpoint data
BreakHandler *handler = d->engine->breakHandler();
foreach (int v8Id, v8BreakpointIds) {
foreach (const BreakpointModelId &id, d->breakpoints.keys()) {
if (d->breakpoints.value(id) == v8Id) {
BreakpointResponse br = handler->response(id);
if (br.functionName.isEmpty()) {
br.functionName = invocationText;
handler->setResponse(id, br);
}
if (handler->state(id) != BreakpointInserted) {
br.lineNumber = breakData.value(
_("sourceLine")).toInt() + 1;
handler->setResponse(id, br);
handler->notifyBreakpointInsertOk(id);
}
const BreakpointModelId id = d->breakpoints.key(v8Id);
if (id.isValid()) {
BreakpointResponse br = handler->response(id);
if (br.functionName.isEmpty()) {
br.functionName = invocationText;
handler->setResponse(id, br);
}
if (handler->state(id) != BreakpointInserted) {
br.lineNumber = breakData.value(
_("sourceLine")).toInt() + 1;
handler->setResponse(id, br);
handler->notifyBreakpointInsertOk(id);
}
}
}
......
......@@ -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++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment