Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 1f598ab4 authored by Volker Krause's avatar Volker Krause

Fix a few range for loops detaching Qt containers

parent 269e859f
......@@ -60,7 +60,8 @@ bool Extractor::load(const QJsonObject &obj, const QString &baseDir)
d->m_type = ICal;
}
for (const auto &filterValue : obj.value(QLatin1String("filter")).toArray()) {
const auto filterArray = obj.value(QLatin1String("filter")).toArray();
for (const auto &filterValue : filterArray) {
ExtractorFilter f;
if (!f.load(filterValue.toObject())) {
return false;
......
......@@ -391,7 +391,8 @@ QJsonArray ExtractorEngine::extract()
void ExtractorEnginePrivate::extractRecursive(KMime::Content *content)
{
QJsonArray aggregatedResult;
for (const auto child : content->contents()) {
const auto children = content->contents();
for (const auto child : children) {
resetContent();
setContent(child);
if (m_mimeContent) {
......@@ -438,9 +439,8 @@ void ExtractorEnginePrivate::extractStructured()
{
if (m_htmlDoc) {
qCDebug(Log) << "Looking for structured annotations...";
for (const auto &v : StructuredDataExtractor::extract(m_htmlDoc.get())) {
m_result.push_back(v);
}
const auto res = StructuredDataExtractor::extract(m_htmlDoc.get());
std::copy(res.begin(), res.end(), std::back_inserter(m_result));
}
}
......@@ -514,7 +514,8 @@ void ExtractorEnginePrivate::extractGeneric()
extractCustom();
// check the unrecognized (vendor-specific) barcodes, if any
for (const auto &code : m_genericPdfExtractor.unrecognizedBarcodes()) {
const auto unrecognizedCodes = m_genericPdfExtractor.unrecognizedBarcodes();
for (const auto &code : unrecognizedCodes) {
m_extractors = m_repo.extractorsForBarcode(code);
extractCustom();
}
......@@ -574,7 +575,8 @@ void ExtractorEnginePrivate::executeScript(const Extractor *extractor)
break;
case Extractor::ICal:
#ifdef HAVE_KCAL
for (const auto &event : m_calendar->events()) {
const auto events = m_calendar->events();
for (const auto &event : events) {
processScriptResult(mainFunc.call({m_engine.toScriptValue(*event.data())}));
}
#endif
......
......@@ -238,8 +238,9 @@ void ExtractorRepositoryPrivate::loadExtractors()
m_extractors.push_back(std::move(e));
}
} else if (doc.isArray()) {
for (const auto &v : doc.array()) {
Extractor e;
const auto extractorArray = doc.array();
for (const auto &v : extractorArray) {
Extractor e;
if (e.load(v.toObject(), fi.absolutePath())) {
m_extractors.push_back(std::move(e));
}
......
......@@ -38,7 +38,8 @@ static void extractBoardingPass(KPkPass::Pass *pass, QJsonObject &resFor)
}
// look for common field names containing the boarding time, if we still have no idea
if (!resFor.contains(QLatin1String("boardingTime"))) {
for (const auto &field : pass->fields()) {
const auto fields = pass->fields();
for (const auto &field : fields) {
if (!field.key().contains(QLatin1String("boarding"), Qt::CaseInsensitive)) {
continue;
}
......
......@@ -55,9 +55,8 @@ static void parseJson(const QByteArray &data, QJsonArray &result)
}
}
if (jsonDoc.isArray()) {
for (const auto &v : jsonDoc.array()) {
result.push_back(v);
}
const auto jsonArray = jsonDoc.array();
std::copy(jsonArray.begin(), jsonArray.end(), std::back_inserter(result));
} else if (jsonDoc.isObject()) {
result.push_back(jsonDoc.object());
}
......
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