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