From c349e78f4590f2ffd8f9bbf0d3cfe29ec708dc4c Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sat, 30 Oct 2021 12:30:45 +0800 Subject: [PATCH] Minor code change according to suggestions --- src/App/Application.cpp | 18 +++++++++--------- src/App/Application.h | 4 ++-- src/App/Document.h | 2 +- src/Gui/ViewProviderDocumentObject.cpp | 2 +- src/Mod/Part/Gui/ViewProviderExt.cpp | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 72db851cba..d51a6740fc 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -633,7 +633,7 @@ Document *Application::getDocumentByPath(const char *path, PathMatchMode checkCa if(!path || !path[0]) return nullptr; if(DocFileMap.empty()) { - for(auto &v : DocMap) { + for(const auto &v : DocMap) { const auto &file = v.second->FileName.getStrValue(); if(file.size()) DocFileMap[FileInfo(file.c_str()).filePath()] = v.second; @@ -643,15 +643,15 @@ Document *Application::getDocumentByPath(const char *path, PathMatchMode checkCa if(it != DocFileMap.end()) return it->second; - if (checkCanonical == MatchAbsolute) + if (checkCanonical == PathMatchMode::MatchAbsolute) return nullptr; std::string filepath = FileInfo(path).filePath(); QString canonicalPath = QFileInfo(QString::fromUtf8(path)).canonicalFilePath(); - for (auto &v : DocMap) { + for (const auto &v : DocMap) { QFileInfo fi(QString::fromUtf8(v.second->FileName.getValue())); if (canonicalPath == fi.canonicalFilePath()) { - if (checkCanonical == MatchCanonical) + if (checkCanonical == PathMatchMode::MatchCanonical) return v.second; bool samePath = (canonicalPath == QString::fromUtf8(filepath.c_str())); FC_WARN("Identical physical path '" << canonicalPath.toUtf8().constData() << "'\n" @@ -778,7 +778,7 @@ std::vector Application::openDocuments(const std::vector break; _pendingDocs = std::move(_pendingDocsReopen); _pendingDocsReopen.clear(); - for(auto &file : _pendingDocs) { + for(const auto &file : _pendingDocs) { auto doc = getDocumentByPath(file.c_str()); if(doc) closeDocument(doc->getName()); @@ -791,7 +791,7 @@ std::vector Application::openDocuments(const std::vector std::vector docs; docs.reserve(newDocs.size()); - for(auto &d : newDocs) { + for(const auto &d : newDocs) { auto doc = d.getDocument(); if(!doc) continue; @@ -843,7 +843,7 @@ std::vector Application::openDocuments(const std::vector seq.next(); } // Close the document for reloading - for(auto doc : docs) + for(const auto doc : docs) closeDocument(doc->getName()); }while(!_pendingDocs.empty()); @@ -883,7 +883,7 @@ Document* Application::openDocumentPrivate(const char * FileName, } // Before creating a new document we check whether the document is already open - auto doc = getDocumentByPath(File.filePath().c_str(), MatchCanonicalWarning); + auto doc = getDocumentByPath(File.filePath().c_str(), PathMatchMode::MatchCanonicalWarning); if(doc) { if(doc->testStatus(App::Document::PartialDoc) || doc->testStatus(App::Document::PartialRestore)) { @@ -897,7 +897,7 @@ Document* Application::openDocumentPrivate(const char * FileName, doc = nullptr; } else if(_allowPartial) { bool reopen = false; - for(auto &name : objNames) { + for(const auto &name : objNames) { auto obj = doc->getObject(name.c_str()); if(!obj || obj->testStatus(App::PartialObject)) { reopen = true; diff --git a/src/App/Application.h b/src/App/Application.h index 738c0e19d7..0d38fcfdab 100644 --- a/src/App/Application.h +++ b/src/App/Application.h @@ -122,7 +122,7 @@ public: App::Document* getDocument(const char *Name) const; /// Path matching mode for getDocumentByPath() - enum PathMatchMode { + enum class PathMatchMode { /// Match by resolving to absolute file path MatchAbsolute = 0, /** Match by absolute path first. If not found then match by resolving @@ -145,7 +145,7 @@ public: * @return Return the document found by matching with the given path */ App::Document* getDocumentByPath(const char *path, - PathMatchMode checkCanonical = MatchAbsolute) const; + PathMatchMode checkCanonical = PathMatchMode::MatchAbsolute) const; /// gets the (internal) name of the document const char * getDocumentName(const App::Document* ) const; diff --git a/src/App/Document.h b/src/App/Document.h index 16e8053fb8..6d0e7c5ec2 100644 --- a/src/App/Document.h +++ b/src/App/Document.h @@ -75,7 +75,7 @@ public: AllowPartialRecompute = 8, // allow recomputing editing object if SkipRecompute is set TempDoc = 9, // Mark as temporary document without prompt for save RestoreError = 10, - LinkStampChanged = 11, // Indicates during restore time if any linked document's time stamp has changed + LinkStampChanged = 11, // Indicates during restore time if any linked document's time stamp has changed }; /** @name Properties */ diff --git a/src/Gui/ViewProviderDocumentObject.cpp b/src/Gui/ViewProviderDocumentObject.cpp index ec1e08c199..e4cc2bbb2b 100644 --- a/src/Gui/ViewProviderDocumentObject.cpp +++ b/src/Gui/ViewProviderDocumentObject.cpp @@ -197,7 +197,7 @@ void ViewProviderDocumentObject::onChanged(const App::Property* prop) // modified then it must be be reversed. if (!testStatus(Gui::ViewStatus::TouchDocument)) { // Note: reverting document modified status like that is not - // appropreiate because we can't tell if there is any other + // appropriate because we can't tell if there is any other // property being changed due to the change of Visibility here. // Temporary setting the Visibility property as 'NoModify' is // the proper way. diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index 64f92b99e9..9bd7037d1f 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -399,7 +399,7 @@ void ViewProviderPartExt::onChanged(const App::Property* prop) updateVisual(); // updateVisual() may not be triggered by any change (e.g. // triggered by an external object through forceUpdate()). And - // since DiffuseColor is not changed here either, do not falsly set + // since DiffuseColor is not changed here either, do not falsely set // the document modified status Base::ObjectStatusLocker guard( App::Property::NoModify, &DiffuseColor);