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:
@@ -165,10 +165,12 @@ QByteArray convertToId(const QMetaObject *mo)
|
|||||||
|
|
||||||
QSet<const QMetaObject *> collectReachableMetaObjects(const QList<QDeclarativeType *> &skip = QList<QDeclarativeType *>())
|
QSet<const QMetaObject *> collectReachableMetaObjects(const QList<QDeclarativeType *> &skip = QList<QDeclarativeType *>())
|
||||||
{
|
{
|
||||||
|
typedef QHash<QByteArray, QSet<QByteArray> > ExtensionHash;
|
||||||
|
|
||||||
QSet<const QMetaObject *> metas;
|
QSet<const QMetaObject *> metas;
|
||||||
metas.insert(FriendlyQObject::qtMeta());
|
metas.insert(FriendlyQObject::qtMeta());
|
||||||
|
|
||||||
QHash<QByteArray, QSet<QByteArray> > extensions;
|
ExtensionHash extensions;
|
||||||
foreach (const QDeclarativeType *ty, QDeclarativeMetaType::qmlTypes()) {
|
foreach (const QDeclarativeType *ty, QDeclarativeMetaType::qmlTypes()) {
|
||||||
qmlTypesByCppName[ty->metaObject()->className()].insert(ty);
|
qmlTypesByCppName[ty->metaObject()->className()].insert(ty);
|
||||||
if (ty->isExtendedType()) {
|
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.
|
// For each export of a base object there can be a single extension object overriding it.
|
||||||
// Example: QDeclarativeGraphicsWidget overrides the QtQuick/QGraphicsWidget export
|
// Example: QDeclarativeGraphicsWidget overrides the QtQuick/QGraphicsWidget export
|
||||||
// of QGraphicsWidget.
|
// 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);
|
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) {
|
foreach (const QByteArray &extensionCppName, extensionCppNames) {
|
||||||
const QSet<const QDeclarativeType *> extensionExports = qmlTypesByCppName.value(extensionCppName);
|
const QSet<const QDeclarativeType *> extensionExports = qmlTypesByCppName.value(extensionCppName);
|
||||||
|
|
||||||
|
|||||||
@@ -503,8 +503,8 @@ void QmlInspectorAdapter::selectObject(const ObjectReference &obj,
|
|||||||
|
|
||||||
void QmlInspectorAdapter::deletePreviews()
|
void QmlInspectorAdapter::deletePreviews()
|
||||||
{
|
{
|
||||||
foreach (const QString &key, m_textPreviews.keys())
|
qDeleteAll(m_textPreviews);
|
||||||
delete m_textPreviews.take(key);
|
m_textPreviews.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlInspectorAdapter::enableTools(const bool enable)
|
void QmlInspectorAdapter::enableTools(const bool enable)
|
||||||
|
|||||||
@@ -1390,13 +1390,7 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data)
|
|||||||
BreakHandler *handler = d->engine->breakHandler();
|
BreakHandler *handler = d->engine->breakHandler();
|
||||||
|
|
||||||
foreach (int v8Id, v8BreakpointIds) {
|
foreach (int v8Id, v8BreakpointIds) {
|
||||||
BreakpointModelId internalId;
|
const BreakpointModelId internalId = d->breakpoints.key(v8Id);
|
||||||
foreach (const BreakpointModelId &id, d->breakpoints.keys()) {
|
|
||||||
if (d->breakpoints.value(id) == v8Id) {
|
|
||||||
internalId = id;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (internalId.isValid()) {
|
if (internalId.isValid()) {
|
||||||
const BreakpointParameters ¶ms = handler->breakpointData(internalId);
|
const BreakpointParameters ¶ms = handler->breakpointData(internalId);
|
||||||
@@ -1426,19 +1420,18 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data)
|
|||||||
//Update breakpoint data
|
//Update breakpoint data
|
||||||
BreakHandler *handler = d->engine->breakHandler();
|
BreakHandler *handler = d->engine->breakHandler();
|
||||||
foreach (int v8Id, v8BreakpointIds) {
|
foreach (int v8Id, v8BreakpointIds) {
|
||||||
foreach (const BreakpointModelId &id, d->breakpoints.keys()) {
|
const BreakpointModelId id = d->breakpoints.key(v8Id);
|
||||||
if (d->breakpoints.value(id) == v8Id) {
|
if (id.isValid()) {
|
||||||
BreakpointResponse br = handler->response(id);
|
BreakpointResponse br = handler->response(id);
|
||||||
if (br.functionName.isEmpty()) {
|
if (br.functionName.isEmpty()) {
|
||||||
br.functionName = invocationText;
|
br.functionName = invocationText;
|
||||||
handler->setResponse(id, br);
|
handler->setResponse(id, br);
|
||||||
}
|
}
|
||||||
if (handler->state(id) != BreakpointInserted) {
|
if (handler->state(id) != BreakpointInserted) {
|
||||||
br.lineNumber = breakData.value(
|
br.lineNumber = breakData.value(
|
||||||
_("sourceLine")).toInt() + 1;
|
_("sourceLine")).toInt() + 1;
|
||||||
handler->setResponse(id, br);
|
handler->setResponse(id, br);
|
||||||
handler->notifyBreakpointInsertOk(id);
|
handler->notifyBreakpointInsertOk(id);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,17 @@ using namespace QmlDebug;
|
|||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
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()
|
QmlRangeEventData::QmlRangeEventData()
|
||||||
{
|
{
|
||||||
@@ -64,9 +75,9 @@ QmlRangeEventData::QmlRangeEventData()
|
|||||||
|
|
||||||
QmlRangeEventData::~QmlRangeEventData()
|
QmlRangeEventData::~QmlRangeEventData()
|
||||||
{
|
{
|
||||||
qDeleteAll(parentHash.values());
|
qDeleteAll(parentHash);
|
||||||
parentHash.clear();
|
parentHash.clear();
|
||||||
qDeleteAll(childrenHash.values());
|
qDeleteAll(childrenHash);
|
||||||
childrenHash.clear();
|
childrenHash.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,17 +101,11 @@ QmlRangeEventData &QmlRangeEventData::operator=(const QmlRangeEventData &ref)
|
|||||||
eventId = ref.eventId;
|
eventId = ref.eventId;
|
||||||
isBindingLoop = ref.isBindingLoop;
|
isBindingLoop = ref.isBindingLoop;
|
||||||
|
|
||||||
qDeleteAll(parentHash.values());
|
qDeleteAll(parentHash);
|
||||||
parentHash.clear();
|
parentHash = cloneEventHash(ref.parentHash);
|
||||||
foreach (const QString &key, ref.parentHash.keys()) {
|
|
||||||
parentHash.insert(key, new QmlRangeEventRelative(ref.parentHash.value(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
qDeleteAll(childrenHash.values());
|
qDeleteAll(childrenHash);
|
||||||
childrenHash.clear();
|
childrenHash = cloneEventHash(ref.childrenHash);
|
||||||
foreach (const QString &key, ref.childrenHash.keys()) {
|
|
||||||
childrenHash.insert(key, new QmlRangeEventRelative(ref.childrenHash.value(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -263,7 +268,7 @@ QV8EventData *QmlProfilerDataModel::v8EventDescription(int eventId) const
|
|||||||
|
|
||||||
void QmlProfilerDataModel::clear()
|
void QmlProfilerDataModel::clear()
|
||||||
{
|
{
|
||||||
qDeleteAll(d->rangeEventDictionary.values());
|
qDeleteAll(d->rangeEventDictionary);
|
||||||
d->rangeEventDictionary.clear();
|
d->rangeEventDictionary.clear();
|
||||||
|
|
||||||
d->endInstanceList.clear();
|
d->endInstanceList.clear();
|
||||||
@@ -1289,8 +1294,8 @@ void QmlProfilerDataModel::QmlProfilerDataModelPrivate::clearQmlRootEvent()
|
|||||||
qmlRootEvent.medianTime = 0;
|
qmlRootEvent.medianTime = 0;
|
||||||
qmlRootEvent.eventId = -1;
|
qmlRootEvent.eventId = -1;
|
||||||
|
|
||||||
qDeleteAll(qmlRootEvent.parentHash.values());
|
qDeleteAll(qmlRootEvent.parentHash);
|
||||||
qDeleteAll(qmlRootEvent.childrenHash.values());
|
qDeleteAll(qmlRootEvent.childrenHash);
|
||||||
qmlRootEvent.parentHash.clear();
|
qmlRootEvent.parentHash.clear();
|
||||||
qmlRootEvent.childrenHash.clear();
|
qmlRootEvent.childrenHash.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,17 @@ QT_END_NAMESPACE
|
|||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
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)
|
QV8EventData &QV8EventData::operator=(const QV8EventData &ref)
|
||||||
{
|
{
|
||||||
if (this == &ref)
|
if (this == &ref)
|
||||||
@@ -58,17 +69,12 @@ QV8EventData &QV8EventData::operator=(const QV8EventData &ref)
|
|||||||
selfPercent = ref.selfPercent;
|
selfPercent = ref.selfPercent;
|
||||||
eventId = ref.eventId;
|
eventId = ref.eventId;
|
||||||
|
|
||||||
qDeleteAll(parentHash.values());
|
qDeleteAll(parentHash);
|
||||||
parentHash.clear();
|
parentHash = cloneEventHash(ref.parentHash);
|
||||||
foreach (const QString &key, ref.parentHash.keys()) {
|
|
||||||
parentHash.insert(key, new QV8EventSub(ref.parentHash.value(key)));
|
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;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,8 +446,12 @@ void QV8ProfilerDataModel::load(QXmlStreamReader &stream)
|
|||||||
d->v8MeasuredTime = cumulatedV8Time;
|
d->v8MeasuredTime = cumulatedV8Time;
|
||||||
|
|
||||||
// find v8events' children and parents
|
// find v8events' children and parents
|
||||||
foreach (int parentIndex, childrenIndexes.keys()) {
|
typedef QHash <int, QString>::ConstIterator ChildIndexConstIt;
|
||||||
QStringList childrenStrings = childrenIndexes.value(parentIndex).split(QLatin1String(","));
|
|
||||||
|
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 childrenTimesStrings = childrenTimes.value(parentIndex).split(QLatin1String(", "));
|
||||||
QStringList parentTimesStrings = parentTimes.value(parentIndex).split(QLatin1String(", "));
|
QStringList parentTimesStrings = parentTimes.value(parentIndex).split(QLatin1String(", "));
|
||||||
for (int ndx = 0; ndx < childrenStrings.count(); ndx++) {
|
for (int ndx = 0; ndx < childrenStrings.count(); ndx++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user