Commit 9965606f authored by Alexander Lohnau's avatar Alexander Lohnau 💬

Fix detaching in for loops

parent cce2a797
...@@ -170,7 +170,7 @@ void UserActionListView::slotCurrentItemChanged(QTreeWidgetItem* item) ...@@ -170,7 +170,7 @@ void UserActionListView::slotCurrentItemChanged(QTreeWidgetItem* item)
QDomDocument UserActionListView::dumpSelectedActions(QDomDocument* mergeDoc) const QDomDocument UserActionListView::dumpSelectedActions(QDomDocument* mergeDoc) const
{ {
QList<QTreeWidgetItem*> list = selectedItems(); const QList<QTreeWidgetItem*> list = selectedItems();
QDomDocument doc; QDomDocument doc;
if (mergeDoc) if (mergeDoc)
doc = *mergeDoc; doc = *mergeDoc;
...@@ -188,7 +188,7 @@ QDomDocument UserActionListView::dumpSelectedActions(QDomDocument* mergeDoc) con ...@@ -188,7 +188,7 @@ QDomDocument UserActionListView::dumpSelectedActions(QDomDocument* mergeDoc) con
void UserActionListView::removeSelectedActions() void UserActionListView::removeSelectedActions()
{ {
QList<QTreeWidgetItem*> list = selectedItems(); const QList<QTreeWidgetItem*> list = selectedItems();
for (auto item : list) { for (auto item : list) {
if (auto* actionItem = dynamic_cast<UserActionListViewItem*>(item)) { if (auto* actionItem = dynamic_cast<UserActionListViewItem*>(item)) {
......
...@@ -124,7 +124,7 @@ KrArcHandler::KrArcHandler(QObject *parent) : QObject(parent) ...@@ -124,7 +124,7 @@ KrArcHandler::KrArcHandler(QObject *parent) : QObject(parent)
QStringLiteral("application/vnd.rar") }; QStringLiteral("application/vnd.rar") };
#ifdef KRARC_QUERY_ENABLED #ifdef KRARC_QUERY_ENABLED
auto mimetypes = KProtocolInfo::archiveMimetypes("krarc"); const auto mimetypes = KProtocolInfo::archiveMimetypes("krarc");
for (const auto &mimetype : mimetypes) for (const auto &mimetype : mimetypes)
krarcArchiveMimetypes.insert(mimetype); krarcArchiveMimetypes.insert(mimetype);
#endif #endif
......
...@@ -599,7 +599,7 @@ bool KrBookmarkHandler::eventFilter(QObject *obj, QEvent *ev) ...@@ -599,7 +599,7 @@ bool KrBookmarkHandler::eventFilter(QObject *obj, QEvent *ev)
// such as Ctrl+W and accelerator keys // such as Ctrl+W and accelerator keys
if (eventType == QEvent::KeyPress && menu) { if (eventType == QEvent::KeyPress && menu) {
auto *kev = dynamic_cast<QKeyEvent *>(ev); auto *kev = dynamic_cast<QKeyEvent *>(ev);
QList<QAction *> acts = menu->actions(); const QList<QAction *> acts = menu->actions();
bool quickSearchStarted = false; bool quickSearchStarted = false;
bool searchInSpecialItems = KConfigGroup(krConfig, "Look&Feel").readEntry("Search in special items", false); bool searchInSpecialItems = KConfigGroup(krConfig, "Look&Feel").readEntry("Search in special items", false);
......
...@@ -124,7 +124,7 @@ void KURLListRequester::keyPressEvent(QKeyEvent *e) ...@@ -124,7 +124,7 @@ void KURLListRequester::keyPressEvent(QKeyEvent *e)
void KURLListRequester::deleteSelectedItems() void KURLListRequester::deleteSelectedItems()
{ {
QList<QListWidgetItem *> selectedItems = urlListBox->selectedItems(); const QList<QListWidgetItem *> selectedItems = urlListBox->selectedItems();
for (QListWidgetItem *item : selectedItems) for (QListWidgetItem *item : selectedItems)
delete item; delete item;
emit changed(); emit changed();
......
...@@ -103,7 +103,8 @@ void SizeCalculator::nextUrl() ...@@ -103,7 +103,8 @@ void SizeCalculator::nextUrl()
nextUrl(); nextUrl();
return; return;
} }
for (FileItem *file : fs->fileItems()) const QList<FileItem *> fileItems = fs->fileItems();
for (FileItem *file : fileItems)
m_nextSubUrls << file->getUrl(); m_nextSubUrls << file->getUrl();
delete fs; delete fs;
} else { } else {
......
...@@ -51,7 +51,7 @@ KFnKeys::KFnKeys(QWidget *parent, KrMainWindow *mainWindow) : ...@@ -51,7 +51,7 @@ KFnKeys::KFnKeys(QWidget *parent, KrMainWindow *mainWindow) :
layout->setSpacing(0); layout->setSpacing(0);
int pos = 0; int pos = 0;
for(QPair<QPushButton *, QPair<QAction *, const QString&>> entry : buttonList) { for(QPair<QPushButton *, QPair<QAction *, const QString&>> entry : qAsConst(buttonList)) {
layout->addWidget(entry.first, 0, pos++); layout->addWidget(entry.first, 0, pos++);
} }
layout->activate(); layout->activate();
......
...@@ -248,7 +248,7 @@ bool JobMan::waitForJobs(bool waitForUserInput) ...@@ -248,7 +248,7 @@ bool JobMan::waitForJobs(bool waitForUserInput)
m_messageBox->addButton(QMessageBox::Abort); m_messageBox->addButton(QMessageBox::Abort);
m_messageBox->addButton(QMessageBox::Cancel); m_messageBox->addButton(QMessageBox::Cancel);
m_messageBox->setDefaultButton(QMessageBox::Cancel); m_messageBox->setDefaultButton(QMessageBox::Cancel);
for (KrJob *job: m_jobs) for (KrJob *job: qAsConst(m_jobs))
connect(job, &KrJob::terminated, this, &JobMan::slotUpdateMessageBox); connect(job, &KrJob::terminated, this, &JobMan::slotUpdateMessageBox);
slotUpdateMessageBox(); slotUpdateMessageBox();
...@@ -258,7 +258,7 @@ bool JobMan::waitForJobs(bool waitForUserInput) ...@@ -258,7 +258,7 @@ bool JobMan::waitForJobs(bool waitForUserInput)
// accepted -> cancel all jobs // accepted -> cancel all jobs
if (result == QMessageBox::Abort) { if (result == QMessageBox::Abort) {
for (KrJob *job: m_jobs) { for (KrJob *job: qAsConst(m_jobs)) {
job->cancel(); job->cancel();
} }
return true; return true;
...@@ -314,7 +314,7 @@ void JobMan::slotControlActionTriggered() ...@@ -314,7 +314,7 @@ void JobMan::slotControlActionTriggered()
if (!anyRunning && m_queueMode) { if (!anyRunning && m_queueMode) {
m_jobs.first()->start(); m_jobs.first()->start();
} else { } else {
for (KrJob *job : m_jobs) { for (KrJob *job : qAsConst(m_jobs)) {
if (anyRunning) if (anyRunning)
job->pause(); job->pause();
else else
...@@ -426,7 +426,7 @@ void JobMan::cleanupMenu() { ...@@ -426,7 +426,7 @@ void JobMan::cleanupMenu() {
void JobMan::updateUI() void JobMan::updateUI()
{ {
int totalPercent = 0; int totalPercent = 0;
for (KrJob *job: m_jobs) { for (KrJob *job: qAsConst(m_jobs)) {
totalPercent += job->percent(); totalPercent += job->percent();
} }
const bool hasJobs = !m_jobs.isEmpty(); const bool hasJobs = !m_jobs.isEmpty();
......
...@@ -237,7 +237,7 @@ void KrViewItemDelegate::cycleEditorSelection() ...@@ -237,7 +237,7 @@ void KrViewItemDelegate::cycleEditorSelection()
EditorSelection currentSelection(editor->selectionStart(), editor->QLINEEDIT_SELECTIONLENGTH); EditorSelection currentSelection(editor->selectionStart(), editor->QLINEEDIT_SELECTIONLENGTH);
auto text = editor->text(); auto text = editor->text();
auto selections = generateFileNameSelections(text); const auto selections = generateFileNameSelections(text);
// try to find current selection in the list // try to find current selection in the list
int currentIndex = 0; int currentIndex = 0;
......
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