From f214713703766a3bd6ff06cb5d3a1b77a410dbce Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Sun, 11 Oct 2020 17:33:07 +0200 Subject: [PATCH] Constify Signed-off-by: Sven Strickroth --- ext/ResizableLib/ResizableWndState.cpp | 2 +- src/Git/GitIndex.cpp | 16 +++---- src/Git/GitPatch.h | 4 +- src/Git/GitRev.h | 2 +- src/Git/GitRevLoglist.h | 6 +-- src/Git/GitStatusListCtrl.h | 22 ++++----- src/Git/TGitPath.cpp | 2 +- src/Git/TGitPath.h | 2 +- src/Git/gitindex.h | 16 +++---- src/TortoiseGitBlame/GitBlameLogList.h | 4 +- src/TortoiseGitBlame/LogListBlameAction.cpp | 2 +- src/TortoiseGitBlame/TortoiseGitBlameData.cpp | 2 +- src/TortoiseGitBlame/TortoiseGitBlameData.h | 6 +-- src/TortoiseIDiff/PicWindow.h | 6 +-- src/TortoiseMerge/BaseView.h | 4 +- src/TortoiseMerge/FilePatchesDlg.h | 4 +- src/TortoiseMerge/FindDlg.h | 16 +++---- src/TortoiseMerge/ViewData.h | 2 +- src/TortoiseMerge/XSplitter.h | 12 ++--- src/TortoiseProc/ColumnManager.cpp | 2 +- src/TortoiseProc/FindDlg.h | 14 +++--- src/TortoiseProc/GitLogList.h | 4 +- src/TortoiseProc/GitLogListAction.cpp | 52 ++++++++++----------- src/TortoiseProc/GitLogListBase.cpp | 54 +++++++++++----------- src/TortoiseProc/GitLogListBase.h | 12 ++--- src/TortoiseProc/GitProgressDlg.h | 6 +-- src/TortoiseProc/GitProgressList.h | 8 ++-- src/TortoiseProc/LogDataVector.cpp | 6 +-- src/TortoiseProc/LogDlg.cpp | 6 +-- src/TortoiseProc/LogDlg.h | 4 +- src/TortoiseProc/LogDlgHelper.h | 8 ++-- src/TortoiseProc/PatchListCtrl.h | 6 +-- src/TortoiseProc/Settings/SettingGitCredential.cpp | 2 +- src/TortoiseProc/Settings/SettingGitCredential.h | 2 +- src/TortoiseProc/Settings/SettingGitRemote.cpp | 2 +- src/TortoiseProc/Settings/SettingGitRemote.h | 6 +-- src/TortoiseProc/Settings/SettingsPropPage.h | 2 +- src/TortoiseProc/SubmoduleDiffDlg.h | 4 +- src/TortoiseProc/SyncDlg.h | 2 +- src/TortoiseProc/TortoiseProc.h | 6 +-- src/TortoiseProc/lanes.h | 4 +- src/TortoiseUDiff/MainWindow.h | 2 +- src/Utils/COMError.h | 12 ++--- src/Utils/DragDropImpl.h | 4 +- src/Utils/MailMsg.cpp | 2 +- src/Utils/MailMsg.h | 4 +- src/Utils/MiscUI/HistoryCombo.h | 6 +-- src/Utils/MiscUI/IconBitmapUtils.cpp | 4 +- src/Utils/MiscUI/IconBitmapUtils.h | 4 +- src/Utils/PathWatcher.h | 4 +- src/Utils/SmartLibgit2Ref.h | 2 +- src/Utils/UniqueQueue.h | 6 +-- 52 files changed, 196 insertions(+), 196 deletions(-) diff --git a/ext/ResizableLib/ResizableWndState.cpp b/ext/ResizableLib/ResizableWndState.cpp index f5e342611..7984cf02b 100644 --- a/ext/ResizableLib/ResizableWndState.cpp +++ b/ext/ResizableLib/ResizableWndState.cpp @@ -71,7 +71,7 @@ BOOL CResizableWndState::SaveWindowRect(LPCTSTR pszName, BOOL bRectOnly) CDPIAware::Instance().UnscaleWindowPlacement(&wp); // use workspace coordinates - RECT& rc = wp.rcNormalPosition; + const RECT& rc = wp.rcNormalPosition; if (bRectOnly) // save size/pos only (normal state) { diff --git a/src/Git/GitIndex.cpp b/src/Git/GitIndex.cpp index 92cd54b9c..f0e4f73be 100644 --- a/src/Git/GitIndex.cpp +++ b/src/Git/GitIndex.cpp @@ -160,7 +160,7 @@ int CGitIndexList::ReadIndex(CString dgitdir) return 0; } -int CGitIndexList::GetFileStatus(const CString& gitdir, const CString& pathorg, git_wc_status2_t& status, __int64 time, __int64 filesize, bool isSymlink, CGitHash* pHash) +int CGitIndexList::GetFileStatus(const CString& gitdir, const CString& pathorg, git_wc_status2_t& status, __int64 time, __int64 filesize, bool isSymlink, CGitHash* pHash) const { size_t index = SearchInSortVector(*this, pathorg, -1, IsIgnoreCase()); @@ -181,7 +181,7 @@ int CGitIndexList::GetFileStatus(const CString& gitdir, const CString& pathorg, return GetFileStatus(repository, gitdir, entry, status, time, filesize, isSymlink); } -int CGitIndexList::GetFileStatus(CAutoRepository& repository, const CString& gitdir, CGitIndex& entry, git_wc_status2_t& status, __int64 time, __int64 filesize, bool isSymlink) +int CGitIndexList::GetFileStatus(CAutoRepository& repository, const CString& gitdir, const CGitIndex& entry, git_wc_status2_t& status, __int64 time, __int64 filesize, bool isSymlink) const { ATLASSERT(!status.assumeValid && !status.skipWorktree); @@ -256,7 +256,7 @@ int CGitIndexList::GetFileStatus(CAutoRepository& repository, const CString& git return 0; } -int CGitIndexList::GetFileStatus(const CString& gitdir, const CString& path, git_wc_status2_t& status, CGitHash* pHash) +int CGitIndexList::GetFileStatus(const CString& gitdir, const CString& path, git_wc_status2_t& status, CGitHash* pHash) const { ATLASSERT(!status.assumeValid && !status.skipWorktree); @@ -324,7 +324,7 @@ bool CGitIndexFileMap::HasIndexChangedOnDisk(const CString& gitdir) int CGitIndexFileMap::LoadIndex(const CString &gitdir) { - SHARED_INDEX_PTR pIndex = std::make_shared(); + auto pIndex = std::make_shared(); if (pIndex->ReadIndex(gitdir)) { @@ -544,7 +544,7 @@ int CGitHeadFileList::ReadHeadHash(const CString& gitdir) return 0; } -bool CGitHeadFileList::CheckHeadUpdate() +bool CGitHeadFileList::CheckHeadUpdate() const { if (this->m_HeadFile.IsEmpty()) return true; @@ -1083,14 +1083,14 @@ void CGitHeadFileMap::CheckHeadAndUpdate(const CString& gitdir, bool ignoreCase) if (ptr.get() && !ptr->CheckHeadUpdate()) return; - ptr = std::make_shared(); - if (ptr->ReadHeadHash(gitdir) || ptr->ReadTree(ignoreCase)) + auto newPtr = std::make_shared(); + if (newPtr->ReadHeadHash(gitdir) || newPtr->ReadTree(ignoreCase)) { SafeClear(gitdir); return; } - this->SafeSet(gitdir, ptr); + this->SafeSet(gitdir, newPtr); return; } diff --git a/src/Git/GitPatch.h b/src/Git/GitPatch.h index 6b2c75c99..7f29de993 100644 --- a/src/Git/GitPatch.h +++ b/src/Git/GitPatch.h @@ -1,6 +1,6 @@ // TortoiseGitMerge - a Diff/Patch program -// Copyright (C) 2012, 2019 - TortoiseGit +// Copyright (C) 2012, 2019-2020 - TortoiseGit // Copyright (C) 2010-2012, 2015 - TortoiseSVN // This program is free software; you can redistribute it and/or @@ -43,7 +43,7 @@ public: * Sets the target path. Use this after getting a new path from CheckPatchPath() */ void SetTargetPath(const CString& targetpath) { m_targetpath = targetpath; m_targetpath.Replace('\\', '/'); } - CString GetTargetPath() { return m_targetpath; } + CString GetTargetPath() const { return m_targetpath; } /** * Finds the best path to apply the patch file. Starting from the targetpath diff --git a/src/Git/GitRev.h b/src/Git/GitRev.h index 2722ad4e2..7b30ede32 100644 --- a/src/Git/GitRev.h +++ b/src/Git/GitRev.h @@ -113,7 +113,7 @@ public: GIT_REV_LIST m_ParentHash; virtual void Clear(); - inline int ParentsCount() {return static_cast(m_ParentHash.size()); } + inline int ParentsCount() const { return static_cast(m_ParentHash.size()); } protected: int ParserFromCommit(GIT_COMMIT *commit); diff --git a/src/Git/GitRevLoglist.h b/src/Git/GitRevLoglist.h index 675489587..2fe507d79 100644 --- a/src/Git/GitRevLoglist.h +++ b/src/Git/GitRevLoglist.h @@ -41,7 +41,7 @@ public: class GitRevLoglistSharedFiles { public: - GitRevLoglistSharedFiles(PSRWLOCK lock, CTGitPathList& files) + GitRevLoglistSharedFiles(PSRWLOCK lock, const CTGitPathList& files) : m_lock(lock) , m_files(files) { @@ -200,7 +200,7 @@ public: return m_Body; } - CString GetSubjectBody(bool crlf = false) + CString GetSubjectBody(bool crlf = false) const { CString ret(m_Subject); if (!crlf) @@ -219,7 +219,7 @@ public: return ret; } - BOOL IsBoundary() { return m_Mark == L'-'; } + BOOL IsBoundary() const { return m_Mark == L'-'; } virtual void Clear() override; diff --git a/src/Git/GitStatusListCtrl.h b/src/Git/GitStatusListCtrl.h index 72e5cf2bf..cec6c4612 100644 --- a/src/Git/GitStatusListCtrl.h +++ b/src/Git/GitStatusListCtrl.h @@ -473,7 +473,7 @@ public: /** * If unversioned files are found (but not necessarily shown) TRUE is returned. */ - BOOL HasUnversionedItems() {return m_bHasUnversionedItems;} + BOOL HasUnversionedItems() const { return m_bHasUnversionedItems; } /** * If there are any change lists defined in the working copy, TRUE is returned @@ -578,7 +578,7 @@ public: /** * Returns the number of selected items */ - LONG GetSelected(){return m_nSelected;}; + LONG GetSelected() const { return m_nSelected; }; /** * Enables dropping of files on the control. @@ -604,20 +604,20 @@ public: /** * Returns the currently used show flags passed to the Show() method. */ - DWORD GetShowFlags() {return m_dwShow;} + DWORD GetShowFlags() const { return m_dwShow; } public: - CString GetLastErrorMessage() {return m_sLastError;} + CString GetLastErrorMessage() const { return m_sLastError; } void BusyCursor(bool bBusy) { m_bWaitCursor = bBusy; } - LONG GetUnversionedCount() { return m_nShownUnversioned; } - LONG GetModifiedCount() { return m_nShownModified; } - LONG GetAddedCount() { return m_nShownAdded; } - LONG GetDeletedCount() { return m_nShownDeleted; } - LONG GetConflictedCount() { return m_nShownConflicted; } - LONG GetFileCount() { return m_nShownFiles; } - LONG GetSubmoduleCount() { return m_nShownSubmodules; } + LONG GetUnversionedCount() const { return m_nShownUnversioned; } + LONG GetModifiedCount() const { return m_nShownModified; } + LONG GetAddedCount() const { return m_nShownAdded; } + LONG GetDeletedCount() const { return m_nShownDeleted; } + LONG GetConflictedCount() const { return m_nShownConflicted; } + LONG GetFileCount() const { return m_nShownFiles; } + LONG GetSubmoduleCount() const { return m_nShownSubmodules; } CAutoReadLock AcquireReadLock() { return CAutoReadLock(m_guard); } CAutoReadWeakLock AcquireReadWeakLock(DWORD timeout) { return CAutoReadWeakLock(m_guard, timeout); } diff --git a/src/Git/TGitPath.cpp b/src/Git/TGitPath.cpp index 57f1acf1b..5102c13ca 100644 --- a/src/Git/TGitPath.cpp +++ b/src/Git/TGitPath.cpp @@ -1665,7 +1665,7 @@ void CTGitPathList::RemovePath(const CTGitPath& path) } } -void CTGitPathList::RemoveItem(CTGitPath & path) +void CTGitPathList::RemoveItem(const CTGitPath& path) { PathVector::iterator it; for(it = m_paths.begin(); it != m_paths.end(); ++it) diff --git a/src/Git/TGitPath.h b/src/Git/TGitPath.h index 7d6d0e836..3130f16ce 100644 --- a/src/Git/TGitPath.h +++ b/src/Git/TGitPath.h @@ -413,7 +413,7 @@ public: /** Removes all paths which are on or in a git admin directory */ void RemoveAdminPaths(); void RemovePath(const CTGitPath& path); - void RemoveItem(CTGitPath &path); + void RemoveItem(const CTGitPath& path); /** * Removes all child items and leaves only the top folders. Useful if you * create the list to remove them (i.e. if you remove a parent folder, the diff --git a/src/Git/gitindex.h b/src/Git/gitindex.h index fe9174b84..9d65b1fe4 100644 --- a/src/Git/gitindex.h +++ b/src/Git/gitindex.h @@ -39,7 +39,7 @@ class CGitIndex { public: CString m_FileName; - __time64_t m_ModifyTime; + mutable __time64_t m_ModifyTime; uint16_t m_Flags; uint16_t m_FlagsExtended; CGitHash m_IndexHash; @@ -55,14 +55,14 @@ public: __time64_t m_LastModifyTime; __int64 m_LastFileSize; BOOL m_bHasConflicts; - inline bool IsIgnoreCase() { return m_iIndexCaps & GIT_INDEX_CAPABILITY_IGNORE_CASE; } + inline bool IsIgnoreCase() const { return m_iIndexCaps & GIT_INDEX_CAPABILITY_IGNORE_CASE; } CGitIndexList(); ~CGitIndexList(); int ReadIndex(CString dotgitdir); - int GetFileStatus(const CString& gitdir, const CString& path, git_wc_status2_t& status, CGitHash* pHash = nullptr); - int GetFileStatus(CAutoRepository& repository, const CString& gitdir, CGitIndex& entry, git_wc_status2_t& status, __int64 time, __int64 filesize, bool isSymlink); + int GetFileStatus(const CString& gitdir, const CString& path, git_wc_status2_t& status, CGitHash* pHash = nullptr) const; + int GetFileStatus(CAutoRepository& repository, const CString& gitdir, const CGitIndex& entry, git_wc_status2_t& status, __int64 time, __int64 filesize, bool isSymlink) const; #ifdef GTEST_INCLUDE_GTEST_GTEST_H_ FRIEND_TEST(GitIndexCBasicGitWithTestRepoFixture, GetFileStatus); #endif @@ -70,10 +70,10 @@ protected: int m_iIndexCaps; __int64 m_iMaxCheckSize; CAutoConfig config; - int GetFileStatus(const CString& gitdir, const CString& path, git_wc_status2_t& status, __int64 time, __int64 filesize, bool isSymlink, CGitHash* pHash = nullptr); + int GetFileStatus(const CString& gitdir, const CString& path, git_wc_status2_t& status, __int64 time, __int64 filesize, bool isSymlink, CGitHash* pHash = nullptr) const; }; -typedef std::shared_ptr SHARED_INDEX_PTR; +typedef std::shared_ptr SHARED_INDEX_PTR; typedef CComCritSecLock CAutoLocker; class CGitIndexFileMap:public std::map @@ -179,13 +179,13 @@ public: int ReadTree(bool ignoreCase); int ReadHeadHash(const CString& gitdir); - bool CheckHeadUpdate(); + bool CheckHeadUpdate() const; private: int ReadTreeRecursive(git_repository& repo, const git_tree* tree, const CString& base); }; -typedef std::shared_ptr SHARED_TREE_PTR; +typedef std::shared_ptr SHARED_TREE_PTR; class CGitHeadFileMap:public std::map { public: diff --git a/src/TortoiseGitBlame/GitBlameLogList.h b/src/TortoiseGitBlame/GitBlameLogList.h index 284f99bd9..cc005effd 100644 --- a/src/TortoiseGitBlame/GitBlameLogList.h +++ b/src/TortoiseGitBlame/GitBlameLogList.h @@ -1,6 +1,6 @@ // TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2008-2011, 2013, 2015, 2017, 2019 - TortoiseGit +// Copyright (C) 2008-2011, 2013, 2015, 2017, 2019-2020 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -25,7 +25,7 @@ class CGitBlameLogList : public CGitLogListBase public: void hideUnimplementedCommands(); void GetParentHashes(GitRevLoglist* pRev, GIT_REV_LIST& parentHash); - virtual void ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CMenu* menu, MAP_HASH_NAME& hashMap) override; + virtual void ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CMenu* menu, const MAP_HASH_NAME& hashMap) override; private: void GetPaths(const CGitHash& hash, std::vector& paths); diff --git a/src/TortoiseGitBlame/LogListBlameAction.cpp b/src/TortoiseGitBlame/LogListBlameAction.cpp index 7280bfebd..64591dc95 100644 --- a/src/TortoiseGitBlame/LogListBlameAction.cpp +++ b/src/TortoiseGitBlame/LogListBlameAction.cpp @@ -70,7 +70,7 @@ void RunTortoiseGitProcWithCurrentRev(const CString& command, const GitRev* pRev CCommonAppUtils::RunTortoiseGitProc(procCmd); } -void CGitBlameLogList::ContextMenuAction(int cmd, int /*FirstSelect*/, int /*LastSelect*/, CMenu* /*menu*/, MAP_HASH_NAME&) +void CGitBlameLogList::ContextMenuAction(int cmd, int /*FirstSelect*/, int /*LastSelect*/, CMenu* /*menu*/, const MAP_HASH_NAME&) { POSITION pos = GetFirstSelectedItemPosition(); int indexNext = GetNextSelectedItem(pos); diff --git a/src/TortoiseGitBlame/TortoiseGitBlameData.cpp b/src/TortoiseGitBlame/TortoiseGitBlameData.cpp index 8a6854da1..faabec0aa 100644 --- a/src/TortoiseGitBlame/TortoiseGitBlameData.cpp +++ b/src/TortoiseGitBlame/TortoiseGitBlameData.cpp @@ -459,7 +459,7 @@ int CTortoiseGitBlameData::FindFirstLineWrapAround(SearchDirection direction, co bool CTortoiseGitBlameData::ContainsOnlyFilename(const CString &filename) const { - return std::all_of(m_Filenames.cbegin(), m_Filenames.cend(), [&filename](auto& name) { return filename == name; }); + return std::all_of(m_Filenames.cbegin(), m_Filenames.cend(), [&filename](const auto& name) { return filename == name; }); } GitRevLoglist* CTortoiseGitBlameData::GetRevForHash(CGitHashMap& HashToRev, const CGitHash& hash, const CGitMailmap* mailmap, CString* err) diff --git a/src/TortoiseGitBlame/TortoiseGitBlameData.h b/src/TortoiseGitBlame/TortoiseGitBlameData.h index 718845f5c..99b6d08b9 100644 --- a/src/TortoiseGitBlame/TortoiseGitBlameData.h +++ b/src/TortoiseGitBlame/TortoiseGitBlameData.h @@ -1,6 +1,6 @@ // TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2008-2013, 2015-2019 - TortoiseGit +// Copyright (C) 2008-2013, 2015-2020 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -45,7 +45,7 @@ public: } int FindNextLine(CGitHash& commithash, int line, bool bUpOrDown=false); // find first line with the given hash starting with given "line" - int FindFirstLine(CGitHash& commithash, int line) + int FindFirstLine(const CGitHash& commithash, int line) { int numberOfLines = static_cast(GetNumberOfLines()); for (int i = (line >= 0 ? line : 0); i < numberOfLines; ++i) @@ -56,7 +56,7 @@ public: return -1; } // find first line of the current block with the given hash starting with given "line" - int FindFirstLineInBlock(CGitHash& commithash, int line) + int FindFirstLineInBlock(const CGitHash& commithash, int line) { while (line >= 0) { diff --git a/src/TortoiseIDiff/PicWindow.h b/src/TortoiseIDiff/PicWindow.h index 1a751a27e..381493f20 100644 --- a/src/TortoiseIDiff/PicWindow.h +++ b/src/TortoiseIDiff/PicWindow.h @@ -180,7 +180,7 @@ public: /// Sets the zoom factor of the image void SetZoom(int Zoom, bool centermouse, bool inzoom = false); /// Returns the currently used zoom factor in which the image is shown. - int GetZoom() {return picscale;} + int GetZoom() const { return picscale; } /// Zooms in (true) or out (false) in nice steps void Zoom(bool in, bool centermouse); /// Sets the 'Other' pic window @@ -196,8 +196,8 @@ public: bool HasMultipleImages(); - int GetHPos() {return nHScrollPos;} - int GetVPos() {return nVScrollPos;} + int GetHPos() const { return nHScrollPos; } + int GetVPos() const { return nVScrollPos; } void SetZoomValue(int z) { picscale = z; InvalidateRect(*this, nullptr, FALSE); } void SetSelectionMode(bool bSelect = true) { bSelectionMode = bSelect; } diff --git a/src/TortoiseMerge/BaseView.h b/src/TortoiseMerge/BaseView.h index 2801a59bb..61183b5ef 100644 --- a/src/TortoiseMerge/BaseView.h +++ b/src/TortoiseMerge/BaseView.h @@ -138,9 +138,9 @@ public: // methods void SetInlineWordDiff(bool bWord) {m_bInlineWordDiff = bWord;} void SetInlineDiff(bool bDiff) {m_bShowInlineDiff = bDiff;} void SetMarkedWord(const CString& word) {m_sMarkedWord = word; BuildMarkedWordArray();} - LPCTSTR GetMarkedWord() { return static_cast(m_sMarkedWord); } + LPCTSTR GetMarkedWord() const { return static_cast(m_sMarkedWord); } int GetMarkedWordCount() const { return m_MarkedWordCount; } - LPCTSTR GetFindString() { return static_cast(m_sFindText); } + LPCTSTR GetFindString() const { return static_cast(m_sFindText); } // Selection methods; all public methods dealing with selection go here static void ClearSelection(); diff --git a/src/TortoiseMerge/FilePatchesDlg.h b/src/TortoiseMerge/FilePatchesDlg.h index 45d6dd828..e41cfde3c 100644 --- a/src/TortoiseMerge/FilePatchesDlg.h +++ b/src/TortoiseMerge/FilePatchesDlg.h @@ -1,4 +1,4 @@ -// TortoiseGitMerge - a Diff/Patch program +// TortoiseGitMerge - a Diff/Patch program // Copyright (C) 2006, 2008, 2010-2011, 2013, 2015 - TortoiseSVN @@ -87,7 +87,7 @@ public: BOOL Init(GitPatch * pPatch, CPatchFilesDlgCallBack * pCallBack, CString sPath, CWnd * pParent); BOOL SetFileStatusAsPatched(CString sPath); - bool HasFiles() {return m_cFileList.GetItemCount()>0;} + bool HasFiles() const { return m_cFileList.GetItemCount() > 0; } enum { IDD = IDD_FILEPATCHES }; protected: GitPatch * m_pPatch; diff --git a/src/TortoiseMerge/FindDlg.h b/src/TortoiseMerge/FindDlg.h index 95c803312..89fc4afd1 100644 --- a/src/TortoiseMerge/FindDlg.h +++ b/src/TortoiseMerge/FindDlg.h @@ -37,14 +37,14 @@ public: CFindDlg(CWnd* pParent = nullptr); // standard constructor virtual ~CFindDlg(); void Create(CWnd* pParent = nullptr, int id = 0); - bool IsTerminating() {return m_bTerminating;} - bool FindNext() {return m_bFindNext;} - bool MatchCase() {return !!m_bMatchCase;} - bool LimitToDiffs() {return !!m_bLimitToDiffs;} - bool WholeWord() {return !!m_bWholeWord;} - bool SearchUp() { return !!m_bSearchUp; } - CString GetFindString() { return m_FindCombo.GetString(); } - CString GetReplaceString() { return m_ReplaceCombo.GetString(); } + bool IsTerminating() const { return m_bTerminating; } + bool FindNext() const { return m_bFindNext; } + bool MatchCase() const { return !!m_bMatchCase; } + bool LimitToDiffs() const { return !!m_bLimitToDiffs; } + bool WholeWord() const { return !!m_bWholeWord; } + bool SearchUp() const { return !!m_bSearchUp; } + CString GetFindString() const { return m_FindCombo.GetString(); } + CString GetReplaceString() const { return m_ReplaceCombo.GetString(); } void SetFindString(const CString& str) { if (!str.IsEmpty()) { m_FindCombo.SetWindowText(str); } } void SetStatusText(const CString& str, COLORREF color = RGB(0, 0, 255)); void SetReadonly(bool bReadonly); diff --git a/src/TortoiseMerge/ViewData.h b/src/TortoiseMerge/ViewData.h index 30d37f960..9ee466543 100644 --- a/src/TortoiseMerge/ViewData.h +++ b/src/TortoiseMerge/ViewData.h @@ -131,7 +131,7 @@ public: m_nMarkedBlocks++; m_data[index].marked = marked; } - bool HasMarkedBlocks() { return m_nMarkedBlocks > 0; } + bool HasMarkedBlocks() const { return m_nMarkedBlocks > 0; } void Clear() { m_data.clear(); m_nMarkedBlocks = 0; } void Reserve(int length) {m_data.reserve(length);} diff --git a/src/TortoiseMerge/XSplitter.h b/src/TortoiseMerge/XSplitter.h index e6f17a35e..3eb11fe83 100644 --- a/src/TortoiseMerge/XSplitter.h +++ b/src/TortoiseMerge/XSplitter.h @@ -87,12 +87,12 @@ public: */ void CenterSplitter(); - int GetOldRowCount() { return m_nOldRows; } - int GetOldColCount() { return m_nOldCols; } - bool HasOldRowSize() { return m_pRowOldSize != nullptr; } - bool HasOldColSize() { return m_pColOldSize != nullptr; } - int GetOldRowSize(int index) { return m_pRowOldSize[index]; } - int GetOldColSize(int index) { return m_pColOldSize[index]; } + int GetOldRowCount() const { return m_nOldRows; } + int GetOldColCount() const { return m_nOldCols; } + bool HasOldRowSize() const { return m_pRowOldSize != nullptr; } + bool HasOldColSize() const { return m_pColOldSize != nullptr; } + int GetOldRowSize(int index) const { return m_pRowOldSize[index]; } + int GetOldColSize(int index) const { return m_pColOldSize[index]; } protected: afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); diff --git a/src/TortoiseProc/ColumnManager.cpp b/src/TortoiseProc/ColumnManager.cpp index 6f131812a..d6a96cbb0 100644 --- a/src/TortoiseProc/ColumnManager.cpp +++ b/src/TortoiseProc/ColumnManager.cpp @@ -197,7 +197,7 @@ bool ColumnManager::IsVisible(int column) const int ColumnManager::GetInvisibleCount() const { - return static_cast(std::count_if(columns.cbegin(), columns.cend(), [](auto& column) { return !column.visible; })); + return static_cast(std::count_if(columns.cbegin(), columns.cend(), [](const auto& column) { return !column.visible; })); } bool ColumnManager::IsRelevant(int column) const diff --git a/src/TortoiseProc/FindDlg.h b/src/TortoiseProc/FindDlg.h index 7081603bd..dc129e597 100644 --- a/src/TortoiseProc/FindDlg.h +++ b/src/TortoiseProc/FindDlg.h @@ -1,6 +1,6 @@ // TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2011-2018 - TortoiseGit +// Copyright (C) 2011-2018, 2020 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -38,12 +38,12 @@ public: virtual ~CFindDlg(); void Create(CWnd* pParent = nullptr) { m_pParent = pParent; CDialog::Create(IDD, pParent); ShowWindow(SW_SHOW); UpdateWindow(); } - bool IsTerminating() {return m_bTerminating;} - bool FindNext() {return m_bFindNext;} - bool MatchCase() {return !!m_bMatchCase;} - bool Regex() {return !!m_bRegex;} - bool IsRef() {return !!m_bIsRef;} - CString GetFindString() {return m_FindString;} + bool IsTerminating() const { return m_bTerminating; } + bool FindNext() const { return m_bFindNext; } + bool MatchCase() const { return !!m_bMatchCase; } + bool Regex() const { return !!m_bRegex; } + bool IsRef() const { return !!m_bIsRef; } + CString GetFindString() const { return m_FindString; } void SetFindString(const CString& str) { if (!str.IsEmpty()) { m_FindCombo.SetWindowText(str); } } void RefreshList(); diff --git a/src/TortoiseProc/GitLogList.h b/src/TortoiseProc/GitLogList.h index 7f1bf54e7..8b2167321 100644 --- a/src/TortoiseProc/GitLogList.h +++ b/src/TortoiseProc/GitLogList.h @@ -1,6 +1,6 @@ // TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2008-2012, 2014-2015, 2017, 2019 - TortoiseGit +// Copyright (C) 2008-2012, 2014-2015, 2017, 2019-2020 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -33,5 +33,5 @@ public: protected: int CherryPickFrom(CString from, CString to); int RevertSelectedCommits(int parent); - void ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CMenu* menu, MAP_HASH_NAME& hashMap) override; + void ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CMenu* menu, const MAP_HASH_NAME& hashMap) override; }; diff --git a/src/TortoiseProc/GitLogListAction.cpp b/src/TortoiseProc/GitLogListAction.cpp index fdb1089b7..7726e705a 100644 --- a/src/TortoiseProc/GitLogListAction.cpp +++ b/src/TortoiseProc/GitLogListAction.cpp @@ -43,7 +43,7 @@ IMPLEMENT_DYNAMIC(CGitLogList, CHintCtrl) -static bool GetFirstEntryStartingWith(STRING_VECTOR& heystack, const CString& needle, CString& result) +static bool GetFirstEntryStartingWith(const STRING_VECTOR& heystack, const CString& needle, CString& result) { auto it = std::find_if(heystack.cbegin(), heystack.cend(), [&needle](const CString& entry) { return CStringUtils::StartsWith(entry, needle); }); if (it == heystack.cend()) @@ -157,7 +157,7 @@ int CGitLogList::CherryPickFrom(CString from, CString to) return 0; } -void CGitLogList::ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CMenu* popmenu, MAP_HASH_NAME& hashMap) +void CGitLogList::ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CMenu* popmenu, const MAP_HASH_NAME& hashMap) { POSITION pos = GetFirstSelectedItemPosition(); int indexNext = GetNextSelectedItem(pos); @@ -490,9 +490,9 @@ void CGitLogList::ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CM else sClipboard = CGit::StripRefName(*selectedBranch); } - else if (hashMap.find(pSelLogEntry->m_CommitHash) != hashMap.cend()) + else if (auto refList = hashMap.find(pSelLogEntry->m_CommitHash); refList != hashMap.cend()) { - for (const auto& ref : hashMap[pSelLogEntry->m_CommitHash]) + for (const auto& ref : refList->second) { if (CStringUtils::StartsWith(ref, L"refs/tags/") && CStringUtils::EndsWith(ref, L"^{}")) sClipboard += ref.Left(ref.GetLength() - static_cast(wcslen(L"^{}"))); @@ -508,8 +508,8 @@ void CGitLogList::ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CM { CString str=pSelLogEntry->m_CommitHash.ToString(); // try to get the tag - if (hashMap.find(pSelLogEntry->m_CommitHash) != hashMap.cend()) - GetFirstEntryStartingWith(hashMap[pSelLogEntry->m_CommitHash], L"refs/tags/", str); + if (auto refList = hashMap.find(pSelLogEntry->m_CommitHash); refList != hashMap.cend()) + GetFirstEntryStartingWith(refList->second, L"refs/tags/", str); CAppUtils::Export(GetParentHWND(), &str, &m_Path); } break; @@ -520,8 +520,8 @@ void CGitLogList::ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CM CString str = pSelLogEntry->m_CommitHash.ToString(); if (branch) str = *branch; - else if (hashMap.find(pSelLogEntry->m_CommitHash) != hashMap.cend()) // try to guess remote branch in order to enable tracking - GetFirstEntryStartingWith(hashMap[pSelLogEntry->m_CommitHash], L"refs/remotes/", str); + else if (auto refList = hashMap.find(pSelLogEntry->m_CommitHash); refList != hashMap.cend()) // try to guess remote branch in order to enable tracking + GetFirstEntryStartingWith(refList->second, L"refs/remotes/", str); CAppUtils::CreateBranchTag(GetParentHWND(), (cmd & 0xFFFF) == ID_CREATE_TAG, &str); ReloadHashMap(); @@ -537,8 +537,8 @@ void CGitLogList::ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CM auto branch = popmenu ? reinterpret_cast(static_cast(popmenu)->GetMenuItemData(cmd & 0xFFFF)) : nullptr; if (branch) str = *branch; - else if (hashMap.find(pSelLogEntry->m_CommitHash) != hashMap.cend()) // try to guess remote branch in order to recommend good branch name and tracking - GetFirstEntryStartingWith(hashMap[pSelLogEntry->m_CommitHash], L"refs/remotes/", str); + else if (auto refList = hashMap.find(pSelLogEntry->m_CommitHash); refList != hashMap.cend()) // try to guess remote branch in order to recommend good branch name and tracking + GetFirstEntryStartingWith(refList->second, L"refs/remotes/", str); CAppUtils::Switch(GetParentHWND(), str); } @@ -746,12 +746,11 @@ void CGitLogList::ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CM CRebaseDlg dlg; dlg.m_Upstream = pSelLogEntry->m_CommitHash.ToString(); // try to guess a branch, optimally a local branch - if (hashMap.find(pSelLogEntry->m_CommitHash) != hashMap.cend()) + if (auto refList = hashMap.find(pSelLogEntry->m_CommitHash); refList != hashMap.cend()) { - const auto& refList = hashMap[pSelLogEntry->m_CommitHash]; - if (!refList.empty()) - dlg.m_Upstream = refList.front(); - for (const auto& ref : refList) + if (!refList->second.empty()) + dlg.m_Upstream = refList->second.front(); + for (const auto& ref : refList->second) { if (CGit::GetShortName(ref, dlg.m_Upstream, L"refs/heads/")) break; @@ -875,11 +874,11 @@ void CGitLogList::ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CM ASSERT(first && last); CString firstBad = first->m_CommitHash.ToString(); - if (hashMap.find(first->m_CommitHash) != hashMap.cend() && !hashMap[first->m_CommitHash].empty()) - firstBad = hashMap[first->m_CommitHash].at(0); + if (auto refList = hashMap.find(first->m_CommitHash); refList != hashMap.cend() && !refList->second.empty()) + firstBad = refList->second.at(0); CString lastGood = last->m_CommitHash.ToString(); - if (hashMap.find(last->m_CommitHash) != hashMap.cend() && !hashMap[last->m_CommitHash].empty()) - lastGood = hashMap[last->m_CommitHash].at(0); + if (auto refList = hashMap.find(last->m_CommitHash); refList != hashMap.cend() && !refList->second.empty()) + lastGood = refList->second.at(0); if (CAppUtils::BisectStart(GetParentHWND(), lastGood, firstBad)) Refresh(); @@ -933,10 +932,10 @@ void CGitLogList::ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CM auto branch = popmenu ? reinterpret_cast(static_cast(popmenu)->GetMenuItemData(cmd)) : nullptr; if (branch && !CStringUtils::StartsWith(*branch, L"refs/remotes/")) guessAssociatedBranch = *branch; - else if (hashMap.find(pSelLogEntry->m_CommitHash) != hashMap.cend()) + else if (auto refList = hashMap.find(pSelLogEntry->m_CommitHash); refList != hashMap.cend()) { - if (!GetFirstEntryStartingWith(hashMap[pSelLogEntry->m_CommitHash], L"refs/heads/", guessAssociatedBranch)) - GetFirstEntryStartingWith(hashMap[pSelLogEntry->m_CommitHash], L"refs/tags/", guessAssociatedBranch); + if (!GetFirstEntryStartingWith(refList->second, L"refs/heads/", guessAssociatedBranch)) + GetFirstEntryStartingWith(refList->second, L"refs/tags/", guessAssociatedBranch); } if (CStringUtils::EndsWith(guessAssociatedBranch, L"^{}")) @@ -997,11 +996,12 @@ void CGitLogList::ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CM CString shortname; if (branch == reinterpret_cast(MAKEINTRESOURCE(IDS_ALL))) { - if (hashMap.find(pSelLogEntry->m_CommitHash) == hashMap.cend()) + auto refList = hashMap.find(pSelLogEntry->m_CommitHash); + if (refList == hashMap.cend()) return; CString currentBranch = L"refs/heads/" + m_CurrentBranch; bool nothingDeleted = true; - for (const auto& ref : hashMap[pSelLogEntry->m_CommitHash]) + for (const auto& ref : refList->second) { if (ref == currentBranch) continue; @@ -1043,8 +1043,8 @@ void CGitLogList::ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CM auto branch = popmenu ? reinterpret_cast(static_cast(popmenu)->GetMenuItemData(cmd & 0xFFFF)) : nullptr; if (branch) str = *branch; - else if (hashMap.find(pSelLogEntry->m_CommitHash) != hashMap.cend() && !hashMap[pSelLogEntry->m_CommitHash].empty()) - str = hashMap[pSelLogEntry->m_CommitHash].at(0); + else if (auto refList = hashMap.find(pSelLogEntry->m_CommitHash); refList != hashMap.cend() && !refList->second.empty()) + str = refList->second.at(0); // we need an URL to complete this command, so error out if we can't get an URL if (CAppUtils::Merge(GetParentHWND(), &str)) { diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index 000aabc76..0cdaabb90 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -503,7 +503,7 @@ void DrawUpstream(HDC hdc, CRect rect, COLORREF color, int bold) ::DeleteObject(pen); } -void CGitLogListBase::DrawTagBranchMessage(NMLVCUSTOMDRAW* pLVCD, CRect& rect, INT_PTR index, std::vector& refList) +void CGitLogListBase::DrawTagBranchMessage(NMLVCUSTOMDRAW* pLVCD, const CRect& rect, INT_PTR index, const std::vector& refList) { GitRevLoglist* data = m_arShownList.SafeGetAt(index); CRect rt=rect; @@ -588,7 +588,7 @@ void CGitLogListBase::DrawTagBranchMessage(NMLVCUSTOMDRAW* pLVCD, CRect& rect, I W_Dc.Detach(); } -void CGitLogListBase::DrawTagBranch(HDC hdc, CDC& W_Dc, HTHEME hTheme, CRect& rect, CRect& rt, LVITEM& rItem, GitRevLoglist* data, std::vector& refList) +void CGitLogListBase::DrawTagBranch(HDC hdc, CDC& W_Dc, HTHEME hTheme, const CRect& rect, CRect& rt, LVITEM& rItem, GitRevLoglist* data, const std::vector& refList) { for (unsigned int i = 0; i < refList.size(); ++i) { @@ -1181,7 +1181,7 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) GitRevLoglist* data = m_arShownList.SafeGetAt(pLVCD->nmcd.dwItemSpec); auto hashMapSharedPtr = m_HashMap; - auto& hashMap = *hashMapSharedPtr; + const auto& hashMap = *hashMapSharedPtr; if ((hashMap.find(data->m_CommitHash) != hashMap.cend() || (!m_superProjectHash.IsEmpty() && data->m_CommitHash == m_superProjectHash)) && !(data->GetRebaseAction() & LOGACTIONS_REBASE_DONE)) { CRect rect; @@ -1669,7 +1669,7 @@ bool CGitLogListBase::IsOnStash(int index) bool CGitLogListBase::IsStash(const GitRev * pSelLogEntry) { auto hashMap = m_HashMap; - auto refList = hashMap.get()->find(pSelLogEntry->m_CommitHash); + const auto refList = hashMap.get()->find(pSelLogEntry->m_CommitHash); if (refList == hashMap.get()->cend()) return false; return any_of((*refList).second, [](const auto& ref) { return ref == L"refs/stash"; }); @@ -1678,7 +1678,7 @@ bool CGitLogListBase::IsStash(const GitRev * pSelLogEntry) bool CGitLogListBase::IsBisect(const GitRev * pSelLogEntry) { auto hashMap = m_HashMap; - auto refList = hashMap->find(pSelLogEntry->m_CommitHash); + const auto refList = hashMap->find(pSelLogEntry->m_CommitHash); if (refList == hashMap->cend()) return false; return any_of((*refList).second, [](const auto& ref) { return CStringUtils::StartsWith(ref, L"refs/bisect/"); }); @@ -1750,7 +1750,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) return; } auto hashMapSharedPtr = m_HashMap; - auto& hashMap = *hashMapSharedPtr; + const auto& hashMap = *hashMapSharedPtr; bool isHeadCommit = (pSelLogEntry->m_CommitHash == headHash); CString currentBranch = L"refs/heads/" + g_Git.GetCurrentBranch(); CTGitPath workingTree(g_Git.m_CurrentDir); @@ -2027,7 +2027,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) size_t index = static_cast(-1); CGit::REF_TYPE type = CGit::REF_TYPE::UNKNOWN; if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry, point, type, hashMap, nullptr, &index)) - popup.SetMenuItemData(ID_MERGEREV, reinterpret_cast(&hashMap[pSelLogEntry->m_CommitHash][index])); + popup.SetMenuItemData(ID_MERGEREV, reinterpret_cast(&hashMap.find(pSelLogEntry->m_CommitHash)->second[index])); } str.Format(IDS_RESET_TO_THIS_FORMAT, static_cast(g_Git.GetCurrentBranch())); @@ -2051,9 +2051,9 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) size_t index = static_cast(-1); CGit::REF_TYPE type = CGit::REF_TYPE::UNKNOWN; if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry, point, type, hashMap, nullptr, &index)) - addCheck(hashMap[pSelLogEntry->m_CommitHash][index]); + addCheck(hashMap.find(pSelLogEntry->m_CommitHash)->second[index]); else - for_each(hashMap[pSelLogEntry->m_CommitHash], addCheck); + for_each(hashMap.find(pSelLogEntry->m_CommitHash)->second, addCheck); CString str2; str2.LoadString(IDS_SWITCH_BRANCH); @@ -2089,7 +2089,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) size_t index = static_cast(-1); CGit::REF_TYPE type = CGit::REF_TYPE::UNKNOWN; if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry, point, type, hashMap, nullptr, &index)) - popup.SetMenuItemData(ID_SWITCHTOREV, reinterpret_cast(&hashMap[pSelLogEntry->m_CommitHash][index])); + popup.SetMenuItemData(ID_SWITCHTOREV, reinterpret_cast(&hashMap.find(pSelLogEntry->m_CommitHash)->second[index])); } if (m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH) && !isStash) @@ -2099,7 +2099,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) size_t index = static_cast(-1); CGit::REF_TYPE type = CGit::REF_TYPE::REMOTE_BRANCH; if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry, point, type, hashMap, nullptr, &index)) - popup.SetMenuItemData(ID_CREATE_BRANCH, reinterpret_cast(&hashMap[pSelLogEntry->m_CommitHash][index])); + popup.SetMenuItemData(ID_CREATE_BRANCH, reinterpret_cast(&hashMap.find(pSelLogEntry->m_CommitHash)->second[index])); } if (m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG) && !isStash) @@ -2277,8 +2277,8 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) popup.AppendMenuIcon(ID_PUSH, str, IDI_PUSH); - if (index != static_cast(-1) && index < hashMap[pSelLogEntry->m_CommitHash].size()) - popup.SetMenuItemData(ID_PUSH, reinterpret_cast(&hashMap[pSelLogEntry->m_CommitHash][index])); + if (auto refList = hashMap.find(pSelLogEntry->m_CommitHash); index != static_cast(-1) && index < refList->second.size()) + popup.SetMenuItemData(ID_PUSH, reinterpret_cast(&refList->second[index])); if (m_ContextMenuMask & GetContextMenuBit(ID_SVNDCOMMIT) && workingTree.HasGitSVNDir()) popup.AppendMenuIcon(ID_SVNDCOMMIT, IDS_MENUSVNDCOMMIT, IDI_COMMIT); @@ -2295,7 +2295,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) if(m_ContextMenuMask &GetContextMenuBit(ID_DELETE)) { - if (hashMap.find(pSelLogEntry->m_CommitHash) != hashMap.end() ) + if (auto refList = hashMap.find(pSelLogEntry->m_CommitHash); refList != hashMap.end() ) { std::vector branchs; auto addCheck = [&](const CString& ref) @@ -2307,9 +2307,9 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) size_t index = static_cast(-1); CGit::REF_TYPE type = CGit::REF_TYPE::UNKNOWN; if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry, point, type, hashMap, nullptr, &index)) - addCheck(hashMap[pSelLogEntry->m_CommitHash][index]); + addCheck(refList->second[index]); else - for_each(hashMap[pSelLogEntry->m_CommitHash], addCheck); + for_each(refList->second, addCheck); CString str; if (branchs.size() == 1) @@ -2361,7 +2361,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) size_t index = static_cast(-1); CGit::REF_TYPE type = CGit::REF_TYPE::UNKNOWN; if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry, point, type, hashMap, nullptr, &index)) - clipSubMenu.SetMenuItemData(ID_COPYCLIPBOARDBRANCHTAG, reinterpret_cast(&hashMap[pSelLogEntry->m_CommitHash][index])); + clipSubMenu.SetMenuItemData(ID_COPYCLIPBOARDBRANCHTAG, reinterpret_cast(&hashMap.find(pSelLogEntry->m_CommitHash)->second[index])); } CString temp; @@ -2875,7 +2875,7 @@ UINT CGitLogListBase::LogThread() // create a copy we can safely work on in this thread auto shared_filter(m_LogFilter); - auto& filter = *shared_filter; + const auto& filter = *shared_filter; TRACE(L"\n===Begin===\n"); //Update work copy item; @@ -2950,7 +2950,7 @@ UINT CGitLogListBase::LogThread() auto mailmap = GitRevLoglist::s_Mailmap; auto hashMapSharedPtr = m_HashMap; - auto& hashMap = *hashMapSharedPtr; + const auto& hashMap = *hashMapSharedPtr; GIT_COMMIT commit; t2 = t1 = GetTickCount64(); @@ -3205,7 +3205,7 @@ void CGitLogListBase::StartLoadingThread() m_LoadingThread->ResumeThread(); } -bool CGitLogListBase::ShouldShowFilter(GitRevLoglist* pRev, const std::unordered_map>& commitChildren, MAP_HASH_NAME& hashMap) +bool CGitLogListBase::ShouldShowFilter(GitRevLoglist* pRev, const std::unordered_map>& commitChildren, const MAP_HASH_NAME& hashMap) { if (m_ShowFilter & FILTERSHOW_ANYCOMMIT) return true; @@ -3213,7 +3213,7 @@ bool CGitLogListBase::ShouldShowFilter(GitRevLoglist* pRev, const std::unordered if ((m_ShowFilter & FILTERSHOW_REFS) && hashMap.find(pRev->m_CommitHash) != hashMap.cend()) { // Keep all refs. - const STRING_VECTOR& refList = hashMap[pRev->m_CommitHash]; + const auto& refList = hashMap.find(pRev->m_CommitHash)->second; for (size_t i = 0; i < refList.size(); ++i) { const CString &str = refList[i]; @@ -3782,14 +3782,14 @@ CString CGitLogListBase::GetToolTipText(int nItem, int nSubItem) return CString(); } -bool CGitLogListBase::IsMouseOnRefLabelFromPopupMenu(const GitRevLoglist* pLogEntry, const CPoint& point, CGit::REF_TYPE& type, MAP_HASH_NAME& hashMap, CString* pShortname /*nullptr*/, size_t* pIndex /*nullptr*/) +bool CGitLogListBase::IsMouseOnRefLabelFromPopupMenu(const GitRevLoglist* pLogEntry, const CPoint& point, CGit::REF_TYPE& type, const MAP_HASH_NAME& hashMap, CString* pShortname /*nullptr*/, size_t* pIndex /*nullptr*/) { POINT pt = point; ScreenToClient(&pt); return IsMouseOnRefLabel(pLogEntry, pt, type, hashMap, pShortname, pIndex); } -bool CGitLogListBase::IsMouseOnRefLabel(const GitRevLoglist* pLogEntry, const POINT& pt, CGit::REF_TYPE& type, MAP_HASH_NAME& hashMap, CString* pShortname /*nullptr*/, size_t* pIndex /*nullptr*/) +bool CGitLogListBase::IsMouseOnRefLabel(const GitRevLoglist* pLogEntry, const POINT& pt, CGit::REF_TYPE& type, const MAP_HASH_NAME& hashMap, CString* pShortname /*nullptr*/, size_t* pIndex /*nullptr*/) { if (!pLogEntry) return false; @@ -3798,17 +3798,17 @@ bool CGitLogListBase::IsMouseOnRefLabel(const GitRevLoglist* pLogEntry, const PO if (refList == hashMap.cend()) return false; - for (size_t i = 0; i < hashMap[pLogEntry->m_CommitHash].size(); ++i) + for (size_t i = 0; i < refList->second.size(); ++i) { - const auto labelpos = m_RefLabelPosMap.find(hashMap[pLogEntry->m_CommitHash][i]); + const auto labelpos = m_RefLabelPosMap.find(refList->second[i]); if (labelpos == m_RefLabelPosMap.cend() || !labelpos->second.PtInRect(pt)) continue; CGit::REF_TYPE foundType; if (pShortname) - *pShortname = CGit::GetShortName(hashMap[pLogEntry->m_CommitHash][i], &foundType); + *pShortname = CGit::GetShortName(refList->second[i], &foundType); else - CGit::GetShortName(hashMap[pLogEntry->m_CommitHash][i], &foundType); + CGit::GetShortName(refList->second[i], &foundType); if (foundType != type && type != CGit::REF_TYPE::UNKNOWN) return false; diff --git a/src/TortoiseProc/GitLogListBase.h b/src/TortoiseProc/GitLogListBase.h index 4c1671b01..a8a199d1a 100644 --- a/src/TortoiseProc/GitLogListBase.h +++ b/src/TortoiseProc/GitLogListBase.h @@ -423,7 +423,7 @@ public: int FillGitLog(std::unordered_set& hashes); protected: CString MessageDisplayStr(GitRev* pLogEntry); - bool ShouldShowFilter(GitRevLoglist* pRev, const std::unordered_map>& commitChildren, MAP_HASH_NAME& hashMap); + bool ShouldShowFilter(GitRevLoglist* pRev, const std::unordered_map>& commitChildren, const MAP_HASH_NAME& hashMap); public: void ShowGraphColumn(bool bShow); CString GetTagInfo(GitRev* pLogEntry) const; @@ -465,7 +465,7 @@ public: void GetTimeRange(CTime &oldest,CTime &latest); protected: virtual void GetParentHashes(GitRev* pRev, GIT_REV_LIST& parentHash); - virtual void ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CMenu* menu, MAP_HASH_NAME& hashMap) = 0; + virtual void ContextMenuAction(int cmd, int FirstSelect, int LastSelect, CMenu* menu, const MAP_HASH_NAME& hashMap) = 0; void UpdateSubmodulePointer() { m_superProjectHash.Empty(); @@ -588,12 +588,12 @@ protected: * pShortname OUT: the short name of that reference label * pIndex OUT: the index value of label of that entry */ - bool IsMouseOnRefLabel(const GitRevLoglist* pLogEntry, const POINT& pt, CGit::REF_TYPE& type, MAP_HASH_NAME& hashMap, CString* pShortname = nullptr, size_t* pIndex = nullptr); - bool IsMouseOnRefLabelFromPopupMenu(const GitRevLoglist* pLogEntry, const CPoint& pt, CGit::REF_TYPE& type, MAP_HASH_NAME& hashMap, CString* pShortname = nullptr, size_t* pIndex = nullptr); + bool IsMouseOnRefLabel(const GitRevLoglist* pLogEntry, const POINT& pt, CGit::REF_TYPE& type, const MAP_HASH_NAME& hashMap, CString* pShortname = nullptr, size_t* pIndex = nullptr); + bool IsMouseOnRefLabelFromPopupMenu(const GitRevLoglist* pLogEntry, const CPoint& pt, CGit::REF_TYPE& type, const MAP_HASH_NAME& hashMap, CString* pShortname = nullptr, size_t* pIndex = nullptr); void FillBackGround(HDC hdc, DWORD_PTR Index, CRect &rect); - void DrawTagBranchMessage(NMLVCUSTOMDRAW* pLVCD, CRect& rect, INT_PTR index, std::vector& refList); - void DrawTagBranch(HDC hdc, CDC& W_Dc, HTHEME hTheme, CRect& rect, CRect& rt, LVITEM& rItem, GitRevLoglist* data, std::vector& refList); + void DrawTagBranchMessage(NMLVCUSTOMDRAW* pLVCD, const CRect& rect, INT_PTR index, const std::vector& refList); + void DrawTagBranch(HDC hdc, CDC& W_Dc, HTHEME hTheme, const CRect& rect, CRect& rt, LVITEM& rItem, GitRevLoglist* data, const std::vector& refList); void DrawGraph(HDC,CRect &rect,INT_PTR index); bool DrawListItemWithMatchesIfEnabled(std::shared_ptr filter, DWORD selectedFilter, NMLVCUSTOMDRAW* pLVCD, LRESULT* pResult); static void DrawListItemWithMatchesRect(NMLVCUSTOMDRAW* pLVCD, const std::vector& ranges, CRect rect, const CString& text, CColors& colors, HTHEME hTheme = nullptr, int txtState = 0); diff --git a/src/TortoiseProc/GitProgressDlg.h b/src/TortoiseProc/GitProgressDlg.h index 59189afe3..e36db323e 100644 --- a/src/TortoiseProc/GitProgressDlg.h +++ b/src/TortoiseProc/GitProgressDlg.h @@ -1,6 +1,6 @@ -// TortoiseGit - a Windows shell extension for easy version control +// TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2008-2017 - TortoiseGit +// Copyright (C) 2008-2017, 2020 - TortoiseGit // Copyright (C) 2003-2008 - TortoiseSVN // This program is free software; you can redistribute it and/or @@ -51,7 +51,7 @@ public: */ void SetItemCount(long count) {if(count) m_ProgList.SetItemCountTotal(count);} - bool DidErrorsOccur() {return m_ProgList.m_bErrorsOccurred;} + bool DidErrorsOccur() const { return m_ProgList.m_bErrorsOccurred; } enum { IDD = IDD_SVNPROGRESS }; diff --git a/src/TortoiseProc/GitProgressList.h b/src/TortoiseProc/GitProgressList.h index afb44d0fc..9135d8d4d 100644 --- a/src/TortoiseProc/GitProgressList.h +++ b/src/TortoiseProc/GitProgressList.h @@ -63,7 +63,7 @@ public: void SetItemCountTotal(long count) { if(count) m_itemCountTotal = count; } void SetItemProgress(long count) { m_itemCount = count;} // do not use SetItemCount here as this overrides the ListBox method bool SetBackgroundImage(UINT nID); - bool DidErrorsOccur() {return m_bErrorsOccurred;} + bool DidErrorsOccur() const { return m_bErrorsOccurred; } bool m_bErrorsOccurred; CWnd *m_pProgressLabelCtrl; CWnd *m_pInfoCtrl; @@ -71,8 +71,8 @@ public: CProgressCtrl *m_pProgControl; ProgressCommand *m_Command; void Cancel(); - volatile BOOL IsCancelled() {return m_bCancelled;} - volatile LONG IsRunning() {return m_bThreadRunning;} + volatile BOOL IsCancelled() const { return m_bCancelled; } + volatile LONG IsRunning() const { return m_bThreadRunning; } CWinThread* m_pThread; CWnd *m_pPostWnd; bool m_bSetTitle; @@ -247,7 +247,7 @@ public: : m_PostCmdCallback(nullptr) {} - void SetPathList(CTGitPathList& pathList) { m_targetPathList = pathList; } + void SetPathList(const CTGitPathList& pathList) { m_targetPathList = pathList; } virtual bool Run(CGitProgressList* list, CString& sWindowTitle, int& m_itemCountTotal, int& m_itemCount) = 0; virtual bool ShowInfo(CString& /*info*/) { return false; } virtual ~ProgressCommand() {} diff --git a/src/TortoiseProc/LogDataVector.cpp b/src/TortoiseProc/LogDataVector.cpp index e5a41ea0c..073a4264f 100644 --- a/src/TortoiseProc/LogDataVector.cpp +++ b/src/TortoiseProc/LogDataVector.cpp @@ -187,7 +187,7 @@ struct SortByParentDate } }; -int CLogDataVector::Fill(std::unordered_set& hashes) +int CLogDataVector::Fill(const std::unordered_set& hashes) { ATLASSERT(m_pLogCache); try @@ -251,7 +251,7 @@ void CLogDataVector::append(CGitHash& sha, bool storeInVector) updateLanes(*r, this->m_Lns, sha); } -void CLogDataVector::setLane(CGitHash& sha) +void CLogDataVector::setLane(const CGitHash& sha) { Lanes* l = &(this->m_Lns); int i = m_FirstFreeLane; @@ -293,7 +293,7 @@ void CLogDataVector::setLane(CGitHash& sha) #endif } -void CLogDataVector::updateLanes(GitRevLoglist& c, Lanes& lns, CGitHash& sha) +void CLogDataVector::updateLanes(GitRevLoglist& c, Lanes& lns, const CGitHash& sha) { // we could get third argument from c.sha(), but we are in fast path here // and c.sha() involves a deep copy, so we accept a little redundancy diff --git a/src/TortoiseProc/LogDlg.cpp b/src/TortoiseProc/LogDlg.cpp index f07bac38d..adc9fa4a7 100644 --- a/src/TortoiseProc/LogDlg.cpp +++ b/src/TortoiseProc/LogDlg.cpp @@ -733,7 +733,7 @@ BOOL FindGitHash(const CString& msg, int offset, CWnd *pWnd) return positions.empty() ? FALSE : TRUE; } -static int DescribeCommit(CGitHash& hash, CString& result) +static int DescribeCommit(const CGitHash& hash, CString& result) { CAutoRepository repo(g_Git.GetGitRepository()); if (!repo) @@ -2581,7 +2581,7 @@ void CLogDlg::OnBnClickedJumpUp() m_LogList.SetSelectionMark(-1); auto hashMapSharedPtr = m_LogList.m_HashMap; - auto& hashMap = *hashMapSharedPtr; + const auto& hashMap = *hashMapSharedPtr; for (int i = index - 1; i >= 0; i--) { @@ -2689,7 +2689,7 @@ void CLogDlg::OnBnClickedJumpDown() m_LogList.SetSelectionMark(-1); auto hashMapSharedPtr = m_LogList.m_HashMap; - auto& hashMap = *hashMapSharedPtr; + const auto& hashMap = *hashMapSharedPtr; for (int i = index + 1; i < m_LogList.GetItemCount(); ++i) { diff --git a/src/TortoiseProc/LogDlg.h b/src/TortoiseProc/LogDlg.h index 5e7ecad88..4fd689e7c 100644 --- a/src/TortoiseProc/LogDlg.h +++ b/src/TortoiseProc/LogDlg.h @@ -68,7 +68,7 @@ public: virtual ~CLogDlg(); void SetParams(const CTGitPath& orgPath, const CTGitPath& path, CString hightlightRevision, CString range, DWORD limit, int limitScale = -1); void SetFilter(const CString& findstr, LONG findtype, bool findregex); - bool IsThreadRunning() { return CGitLogListBase::s_bThreadRunning == TRUE; } + bool IsThreadRunning() const { return CGitLogListBase::s_bThreadRunning == TRUE; } void SetSelect(bool bSelect) {m_bSelect = bSelect;} void ContinuousSelection(bool bCont = true) {m_bSelectionMustBeContinuous = bCont;} void SingleSelection(bool bSingle = true) {m_bSelectionMustBeSingle = bSingle;} @@ -80,7 +80,7 @@ public: * Provides selected commit hash if available, call after OK return from here * Empty if none **/ - std::vector GetSelectedHash(){ return m_sSelectedHash; } + std::vector GetSelectedHash() const { return m_sSelectedHash; } // Dialog Data enum { IDD = IDD_LOGMESSAGE }; diff --git a/src/TortoiseProc/LogDlgHelper.h b/src/TortoiseProc/LogDlgHelper.h index e4fa28d35..a93af0b59 100644 --- a/src/TortoiseProc/LogDlgHelper.h +++ b/src/TortoiseProc/LogDlgHelper.h @@ -1,7 +1,7 @@ // TortoiseGit - a Windows shell extension for easy version control // Copyright (C) 2003-2007 - TortoiseSVN -// Copyright (C) 2008-2019 - TortoiseGit +// Copyright (C) 2008-2020 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -68,15 +68,15 @@ public: } void ClearAll(); int ParserFromLog(CTGitPath* path = nullptr, DWORD count = 0, DWORD infomask = CGit::LOG_INFO_STAT | CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE, CString* range = nullptr); - int Fill(std::unordered_set& hashes); + int Fill(const std::unordered_set& hashes); Lanes m_Lns; int m_FirstFreeLane; // Log order: LOG_ORDER_CHRONOLOGIALREVERSED, LOG_ORDER_TOPOORDER, LOG_ORDER_DATEORDER int m_logOrderBy; MAP_HASH_REV m_HashMap; - void updateLanes(GitRevLoglist& c, Lanes& lns, CGitHash& sha); - void setLane(CGitHash& sha) ; + void updateLanes(GitRevLoglist& c, Lanes& lns, const CGitHash& sha); + void setLane(const CGitHash& sha); void append(CGitHash& sha, bool storeInVector); #if 0 diff --git a/src/TortoiseProc/PatchListCtrl.h b/src/TortoiseProc/PatchListCtrl.h index d96cb4776..411e38471 100644 --- a/src/TortoiseProc/PatchListCtrl.h +++ b/src/TortoiseProc/PatchListCtrl.h @@ -1,6 +1,6 @@ -// TortoiseGit - a Windows shell extension for easy version control +// TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2009-2011, 2015-2016, 2018 - TortoiseGit +// Copyright (C) 2009-2011, 2015-2016, 2018, 2020 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -48,7 +48,7 @@ public: STATUS_MASK = 0xFFFF, }; - DWORD GetMenuMask(int x){return 1<EnableWindow(enable && canModifySystem); } -BOOL CSettingGitCredential::IsUrlExist(CString &text) +BOOL CSettingGitCredential::IsUrlExist(const CString& text) { CString str; for(int i = 0; i < m_ctrlUrlList.GetCount();i++) diff --git a/src/TortoiseProc/Settings/SettingGitCredential.h b/src/TortoiseProc/Settings/SettingGitCredential.h index e001bdc3a..7f3644974 100644 --- a/src/TortoiseProc/Settings/SettingGitCredential.h +++ b/src/TortoiseProc/Settings/SettingGitCredential.h @@ -155,7 +155,7 @@ protected: virtual BOOL OnApply() override; void EnableAdvancedOptions(); - BOOL IsUrlExist(CString &text); + BOOL IsUrlExist(const CString& text); void AddConfigType(int &index, CString text, bool add = true); void AddSimpleCredential(int &index, CString text, bool add = true); diff --git a/src/TortoiseProc/Settings/SettingGitRemote.cpp b/src/TortoiseProc/Settings/SettingGitRemote.cpp index d135e7bad..8d82dee4d 100644 --- a/src/TortoiseProc/Settings/SettingGitRemote.cpp +++ b/src/TortoiseProc/Settings/SettingGitRemote.cpp @@ -188,7 +188,7 @@ void CSettingGitRemote::OnBnClickedButtonAdd() this->OnApply(); } -BOOL CSettingGitRemote::IsRemoteExist(CString &remote) +BOOL CSettingGitRemote::IsRemoteExist(const CString& remote) { CString str; for(int i=0;im_Rev1 = rev1; diff --git a/src/TortoiseProc/TortoiseProc.h b/src/TortoiseProc/TortoiseProc.h index 47140b3d3..a4cd8a561 100644 --- a/src/TortoiseProc/TortoiseProc.h +++ b/src/TortoiseProc/TortoiseProc.h @@ -1,6 +1,6 @@ -// TortoiseGit - a Windows shell extension for easy version control +// TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2008-2013, 2016-2018 - TortoiseGit +// Copyright (C) 2008-2013, 2016-2018, 2020 - TortoiseGit // Copyright (C) 2003-2008 - TortoiseSVN // This program is free software; you can redistribute it and/or @@ -59,7 +59,7 @@ public: ULONG_PTR m_gdiplusToken; - HWND GetExplorerHWND() { return ::IsWindow(hWndExplorer) ? hWndExplorer : nullptr; } + HWND GetExplorerHWND() const { return ::IsWindow(hWndExplorer) ? hWndExplorer : nullptr; } // Implementation private: diff --git a/src/TortoiseProc/lanes.h b/src/TortoiseProc/lanes.h index ae4582884..4b577f35e 100644 --- a/src/TortoiseProc/lanes.h +++ b/src/TortoiseProc/lanes.h @@ -65,7 +65,7 @@ public: , NODE_L(0) , NODE_R(0) {} - bool isEmpty() { return typeVec.empty(); } + bool isEmpty() const { return typeVec.empty(); } void init(const CGitHash& expectedSha); void clear(); bool isFork(const CGitHash& sha, bool& isDiscontinuity); @@ -81,7 +81,7 @@ public: void afterBranch(); void afterApplied(); void nextParent(const CGitHash& sha); - void getLanes(QVector &ln) { ln = typeVec; } // O(1) vector is implicitly shared + void getLanes(QVector& ln) const { ln = typeVec; } // O(1) vector is implicitly shared private: int findNextSha(const CGitHash& next, int pos); diff --git a/src/TortoiseUDiff/MainWindow.h b/src/TortoiseUDiff/MainWindow.h index 46c2f10c1..e370ef2ee 100644 --- a/src/TortoiseUDiff/MainWindow.h +++ b/src/TortoiseUDiff/MainWindow.h @@ -44,7 +44,7 @@ public: bool RegisterAndCreateWindow(); LRESULT SendEditor(UINT Msg, WPARAM wParam = 0, LPARAM lParam = 0); - HWND GetHWNDEdit() { return m_hWndEdit; } + HWND GetHWNDEdit() const { return m_hWndEdit; } bool LoadFile(LPCTSTR filename); bool LoadFile(HANDLE hFile); bool SaveFile(LPCTSTR filename); diff --git a/src/Utils/COMError.h b/src/Utils/COMError.h index 6908d1367..ce2c52403 100644 --- a/src/Utils/COMError.h +++ b/src/Utils/COMError.h @@ -1,4 +1,4 @@ -// TortoiseGit - a Windows shell extension for easy version control +// TortoiseGit - a Windows shell extension for easy version control // Copyright (C) 2009 - TortoiseSVN @@ -24,11 +24,11 @@ public: COMError(HRESULT hr); virtual ~COMError(); - std::wstring GetMessage() {return message;} - std::wstring GetDescription() {return description;} - std::wstring GetMessageAndDescription() { return message + L'\n' + description; } - std::wstring GetSource() {return source;} - std::wstring GetUUID() {return uuid;} + std::wstring GetMessage() const { return message; } + std::wstring GetDescription() const { return description; } + std::wstring GetMessageAndDescription() const { return message + L'\n' + description; } + std::wstring GetSource() const { return source; } + std::wstring GetUUID() const { return uuid; } private: std::wstring message; diff --git a/src/Utils/DragDropImpl.h b/src/Utils/DragDropImpl.h index 1b8497e32..ab61da686 100644 --- a/src/Utils/DragDropImpl.h +++ b/src/Utils/DragDropImpl.h @@ -324,8 +324,8 @@ public: // IDragSourceHelper HRESULT InitializeFromBitmap(HBITMAP hBitmap, - POINT& pt, // cursor position in client coords of the window - RECT& rc, // selected item's bounding rect + const POINT& pt, // cursor position in client coords of the window + const RECT& rc, // selected item's bounding rect IDataObject* pDataObject, BOOL allowDropDescription=TRUE, COLORREF crColorKey=GetSysColor(COLOR_WINDOW)// color of the window used for transparent effect. diff --git a/src/Utils/MailMsg.cpp b/src/Utils/MailMsg.cpp index de29b7478..3320280c4 100644 --- a/src/Utils/MailMsg.cpp +++ b/src/Utils/MailMsg.cpp @@ -194,7 +194,7 @@ BOOL CMailMsg::Send() // add attachments std::vector attachments; - std::for_each(m_attachments.cbegin(), m_attachments.cend(), [&attachments](auto& attachment) + std::for_each(m_attachments.cbegin(), m_attachments.cend(), [&attachments](const auto& attachment) { MapiFileDescW fileDesc = { 0 }; fileDesc.nPosition = 0xFFFFFFFF; diff --git a/src/Utils/MailMsg.h b/src/Utils/MailMsg.h index 8a939a380..6fb806362 100644 --- a/src/Utils/MailMsg.h +++ b/src/Utils/MailMsg.h @@ -4,7 +4,7 @@ Copyright (c) 2003, Michael Carruth All rights reserved. - Adjusted by Sven Strickroth , 2011-2018 + Adjusted by Sven Strickroth , 2011-2020 * added flag to show mail compose dialog * make it work with 32-64bit inconsistencies (http://msdn.microsoft.com/en-us/library/dd941355.aspx) * auto extract filenames of attachments @@ -90,7 +90,7 @@ public: static BOOL DetectMailClient(CString& sMailClientName); BOOL Send(); - CString GetLastErrorMsg(){ return m_sErrorMsg; } + CString GetLastErrorMsg() const { return m_sErrorMsg; } protected: MailAddress m_from; diff --git a/src/Utils/MiscUI/HistoryCombo.h b/src/Utils/MiscUI/HistoryCombo.h index 999b68db6..3b91dcd5b 100644 --- a/src/Utils/MiscUI/HistoryCombo.h +++ b/src/Utils/MiscUI/HistoryCombo.h @@ -1,6 +1,6 @@ -// TortoiseGit - a Windows shell extension for easy version control +// TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2008-2014 - TortoiseGit +// Copyright (C) 2008-2014, 2020 - TortoiseGit // Copyright (C) 2003-2008 - TortoioseSVN // This program is free software; you can redistribute it and/or @@ -162,7 +162,7 @@ protected: * It must return true to prevent the default processing for the * return key. The default implementation returns false. */ - virtual bool OnReturnKeyPressed() { return m_bWantReturn; } + virtual bool OnReturnKeyPressed() const { return m_bWantReturn; } protected: CStringArray m_arEntries; diff --git a/src/Utils/MiscUI/IconBitmapUtils.cpp b/src/Utils/MiscUI/IconBitmapUtils.cpp index 53696d92d..693da66ae 100644 --- a/src/Utils/MiscUI/IconBitmapUtils.cpp +++ b/src/Utils/MiscUI/IconBitmapUtils.cpp @@ -216,7 +216,7 @@ HRESULT IconBitmapUtils::ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC h return S_OK; } -bool IconBitmapUtils::HasAlpha(__in Gdiplus::ARGB *pargb, SIZE& sizImage, int cxRow) const +bool IconBitmapUtils::HasAlpha(__in Gdiplus::ARGB* pargb, const SIZE& sizImage, int cxRow) const { ULONG cxDelta = cxRow - sizImage.cx; for (ULONG y = sizImage.cy; y; --y) @@ -233,7 +233,7 @@ bool IconBitmapUtils::HasAlpha(__in Gdiplus::ARGB *pargb, SIZE& sizImage, int cx return false; } -HRESULT IconBitmapUtils::ConvertToPARGB32(HDC hdc, __inout Gdiplus::ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow) const +HRESULT IconBitmapUtils::ConvertToPARGB32(HDC hdc, __inout Gdiplus::ARGB* pargb, HBITMAP hbmp, const SIZE& sizImage, int cxRow) const { BITMAPINFO bmi = { 0 }; bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); diff --git a/src/Utils/MiscUI/IconBitmapUtils.h b/src/Utils/MiscUI/IconBitmapUtils.h index 2faf873bf..e9a17d5e7 100644 --- a/src/Utils/MiscUI/IconBitmapUtils.h +++ b/src/Utils/MiscUI/IconBitmapUtils.h @@ -43,8 +43,8 @@ public: HBITMAP IconToBitmapPARGB32(HINSTANCE hInst, UINT uIcon); HRESULT Create32BitHBITMAP(HDC hdc, const SIZE *psize, __deref_opt_out void **ppvBits, __out HBITMAP* phBmp) const; HRESULT ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, SIZE& sizIcon); - bool HasAlpha(__in Gdiplus::ARGB *pargb, SIZE& sizImage, int cxRow) const; - HRESULT ConvertToPARGB32(HDC hdc, __inout Gdiplus::ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow) const; + bool HasAlpha(__in Gdiplus::ARGB* pargb, const SIZE& sizImage, int cxRow) const; + HRESULT ConvertToPARGB32(HDC hdc, __inout Gdiplus::ARGB* pargb, HBITMAP hbmp, const SIZE& sizImage, int cxRow) const; private: diff --git a/src/Utils/PathWatcher.h b/src/Utils/PathWatcher.h index 7ee39799f..50e5cd479 100644 --- a/src/Utils/PathWatcher.h +++ b/src/Utils/PathWatcher.h @@ -1,4 +1,4 @@ -// TortoiseGit - a Windows shell extension for easy version control +// TortoiseGit - a Windows shell extension for easy version control // External Cache Copyright (C) 2007-2008, 2012 - TortoiseSVN @@ -57,7 +57,7 @@ public: /** * Returns the number of recursively watched paths. */ - int GetNumberOfWatchedPaths() {return watchedPaths.GetCount();} + int GetNumberOfWatchedPaths() const { return watchedPaths.GetCount(); } /** * Stops the watching thread. diff --git a/src/Utils/SmartLibgit2Ref.h b/src/Utils/SmartLibgit2Ref.h index 69d51892e..bef633401 100644 --- a/src/Utils/SmartLibgit2Ref.h +++ b/src/Utils/SmartLibgit2Ref.h @@ -230,7 +230,7 @@ class CAutoConfig : public CSmartLibgit2Ref public: CAutoConfig() {} - CAutoConfig(CAutoRepository &repo) + CAutoConfig(const CAutoRepository& repo) { git_repository_config(&m_Ref, repo); } diff --git a/src/Utils/UniqueQueue.h b/src/Utils/UniqueQueue.h index c87672559..c2c7fd792 100644 --- a/src/Utils/UniqueQueue.h +++ b/src/Utils/UniqueQueue.h @@ -1,6 +1,6 @@ -// TortoiseGit - a Windows shell extension for easy version control +// TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2013 - TortoiseGit +// Copyright (C) 2013, 2020 - TortoiseGit // Copyright (C) 2010-2011, 2015 - TortoiseSVN // This program is free software; you can redistribute it and/or @@ -49,7 +49,7 @@ public: T Pop(); size_t erase(const T &value); size_t size() const { return m_Queue.size(); } - bool empty() { return m_Queue.empty(); } + bool empty() const { return m_Queue.empty(); } private: struct UniqueQueueStruct { -- 2.11.4.GIT