From 7a0e239240ceb58230a11b64fe8c8a63d6854c30 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Thu, 4 May 2017 22:09:30 +0200 Subject: cmFileMonitor: use cmDeleteAll --- Source/cmFileMonitor.cxx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx index ed794c3..499ee84 100644 --- a/Source/cmFileMonitor.cxx +++ b/Source/cmFileMonitor.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFileMonitor.h" +#include "cmAlgorithms.h" #include "cmsys/SystemTools.hxx" #include @@ -36,12 +37,7 @@ public: class cmVirtualDirectoryWatcher : public cmIBaseWatcher { public: - ~cmVirtualDirectoryWatcher() override - { - for (auto i : this->Children) { - delete i.second; - } - } + ~cmVirtualDirectoryWatcher() override { cmDeleteAll(this->Children); } cmIBaseWatcher* Find(const std::string& ps) { @@ -102,9 +98,7 @@ public: void Reset() { - for (auto c : this->Children) { - delete c.second; - } + cmDeleteAll(this->Children); this->Children.clear(); } -- cgit v0.12 From a57b30bb6037977cb0c8023e758a0850915334eb Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Thu, 4 May 2017 22:12:06 +0200 Subject: QtDialog: add missing emit keywords --- Source/QtDialog/FirstConfigure.cxx | 2 +- Source/QtDialog/QCMakeWidgets.cxx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx index 2f1df4f..b193a27 100644 --- a/Source/QtDialog/FirstConfigure.cxx +++ b/Source/QtDialog/FirstConfigure.cxx @@ -130,7 +130,7 @@ bool StartCompilerSetup::crossCompilerSetup() const void StartCompilerSetup::onSelectionChanged(bool on) { if (on) { - selectionChanged(); + emit selectionChanged(); } } diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx index 6a55a76..7f0cafa 100644 --- a/Source/QtDialog/QCMakeWidgets.cxx +++ b/Source/QtDialog/QCMakeWidgets.cxx @@ -54,11 +54,11 @@ void QCMakeFilePathEditor::chooseFile() title = tr("Select File for %1"); title = title.arg(this->Variable); } - this->fileDialogExists(true); + emit this->fileDialogExists(true); path = QFileDialog::getOpenFileName(this, title, info.absolutePath(), QString(), CM_NULLPTR, QFileDialog::DontResolveSymlinks); - this->fileDialogExists(false); + emit this->fileDialogExists(false); if (!path.isEmpty()) { this->setText(QDir::fromNativeSeparators(path)); @@ -76,11 +76,11 @@ void QCMakePathEditor::chooseFile() title = tr("Select Path for %1"); title = title.arg(this->Variable); } - this->fileDialogExists(true); + emit this->fileDialogExists(true); path = QFileDialog::getExistingDirectory(this, title, this->text(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); - this->fileDialogExists(false); + emit this->fileDialogExists(false); if (!path.isEmpty()) { this->setText(QDir::fromNativeSeparators(path)); } -- cgit v0.12 From 377d4df2795ad501aa7a08cf5c2ac0ef1208c362 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Thu, 4 May 2017 22:19:23 +0200 Subject: QCMakeCacheView: avoid temporary containers for iteration --- Source/QtDialog/QCMakeCacheView.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 9f5208a..29f8daf 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -254,8 +254,11 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) QStandardItem* root = this->invisibleRootItem(); - foreach (QString key, newPropsTree.keys()) { - QCMakePropertyList props2 = newPropsTree[key]; + for (QMap::const_iterator iter = + newPropsTree.begin(); + iter != newPropsTree.end(); ++iter) { + QString const& key = iter.key(); + QCMakePropertyList const& props2 = iter.value(); QList parentItems; parentItems.append( @@ -280,8 +283,11 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) } } - foreach (QString key, newPropsTree2.keys()) { - QCMakePropertyList props2 = newPropsTree2[key]; + for (QMap::const_iterator iter = + newPropsTree2.begin(); + iter != newPropsTree2.end(); ++iter) { + QString const& key = iter.key(); + QCMakePropertyList const& props2 = iter.value(); QStandardItem* parentItem = new QStandardItem(key.isEmpty() ? tr("Ungrouped Entries") : key); -- cgit v0.12 From 726b3b6f756e8b486549271062c40d53f996e404 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Thu, 4 May 2017 22:23:46 +0200 Subject: QtDialog: add reference in foreach --- Source/QtDialog/CMakeSetupDialog.cxx | 6 +++--- Source/QtDialog/QCMake.cxx | 4 ++-- Source/QtDialog/QCMakeCacheView.cxx | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 111b28a..3541da4 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -990,10 +990,10 @@ void CMakeSetupDialog::removeSelectedCacheEntries() { QModelIndexList idxs = this->CacheValues->selectionModel()->selectedRows(); QList pidxs; - foreach (QModelIndex i, idxs) { + foreach (QModelIndex const& i, idxs) { pidxs.append(i); } - foreach (QPersistentModelIndex pi, pidxs) { + foreach (QPersistentModelIndex const& pi, pidxs) { this->CacheValues->model()->removeRow(pi.row(), pi.parent()); } } @@ -1152,7 +1152,7 @@ void CMakeSetupDialog::showUserChanges() QString command; QString cache; - foreach (QCMakeProperty prop, changes) { + foreach (QCMakeProperty const& prop, changes) { QString type; switch (prop.Type) { case QCMakeProperty::BOOL: diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index abeff97..28820a6 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -219,14 +219,14 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) } // remove some properites - foreach (QString s, toremove) { + foreach (QString const& s, toremove) { this->CMakeInstance->UnwatchUnusedCli(s.toLocal8Bit().data()); state->RemoveCacheEntry(s.toLocal8Bit().data()); } // add some new properites - foreach (QCMakeProperty s, props) { + foreach (QCMakeProperty const& s, props) { this->CMakeInstance->WatchUnusedCli(s.Key.toLocal8Bit().data()); if (s.Type == QCMakeProperty::BOOL) { diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 29f8daf..67191a9 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -47,7 +47,7 @@ protected: } // check all strings for a match - foreach (QString str, strs) { + foreach (QString const& str, strs) { if (str.contains(this->filterRegExp())) { return true; } @@ -236,12 +236,12 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) qSort(newP); qSort(newP2); int row_count = 0; - foreach (QCMakeProperty p, newP) { + foreach (QCMakeProperty const& p, newP) { this->insertRow(row_count); this->setPropertyData(this->index(row_count, 0), p, true); row_count++; } - foreach (QCMakeProperty p, newP2) { + foreach (QCMakeProperty const& p, newP2) { this->insertRow(row_count); this->setPropertyData(this->index(row_count, 0), p, false); row_count++; @@ -399,7 +399,7 @@ void QCMakeCacheModel::breakProperties( { QMap tmp; // return a map of properties grouped by prefixes, and sorted - foreach (QCMakeProperty p, props) { + foreach (QCMakeProperty const& p, props) { QString prefix = QCMakeCacheModel::prefix(p.Key); tmp[prefix].append(p); } -- cgit v0.12 From 1ffe47e37f734620825b6eb6f3147b53f091ca83 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Thu, 4 May 2017 22:26:36 +0200 Subject: QCMakeCacheView: prever QVector over QList --- Source/QtDialog/QCMakeCacheView.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 67191a9..08c2d58 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -429,7 +429,7 @@ QCMakePropertyList QCMakeCacheModel::properties() const return props; } - QList idxs; + QVector idxs; idxs.append(this->index(0, 0)); // walk the entire model for property entries @@ -454,7 +454,7 @@ QCMakePropertyList QCMakeCacheModel::properties() const (idxs.last().row() + 1) >= rowCount(idxs.last().parent()) || #endif !idxs.last().sibling(idxs.last().row() + 1, 0).isValid())) { - idxs.removeLast(); + idxs.remove(idxs.size() - 1); } if (!idxs.isEmpty()) { idxs.last() = idxs.last().sibling(idxs.last().row() + 1, 0); -- cgit v0.12 From 422359fe79b9313a45aff6cdbb6ef36d6fc52a46 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Thu, 4 May 2017 22:39:21 +0200 Subject: CMakeSetupDialog: use multi-arg --- Source/QtDialog/CMakeSetupDialog.cxx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 3541da4..57f8e10 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -1175,12 +1175,9 @@ void CMakeSetupDialog::showUserChanges() value = prop.Value.toString(); } - QString line("%1:%2="); - line = line.arg(prop.Key); - line = line.arg(type); - - command += QString("-D%1\"%2\" ").arg(line).arg(value); - cache += QString("%1%2\n").arg(line).arg(value); + QString const line = QString("%1:%2=").arg(prop.Key, type); + command += QString("-D%1\"%2\" ").arg(line, value); + cache += QString("%1%2\n").arg(line, value); } textedit->append(tr("Commandline options:")); -- cgit v0.12