• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revisão29187 (tree)
Hora2021-05-02 23:56:47
Autorstefankueng

Mensagem de Log

more cleanup

Mudança Sumário

Diff

--- trunk/src/TortoiseProc/LogFile.cpp (revision 29186)
+++ trunk/src/TortoiseProc/LogFile.cpp (revision 29187)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2007, 2010-2011, 2014-2016 - TortoiseSVN
3+// Copyright (C) 2007, 2010-2011, 2014-2016, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -23,12 +23,12 @@
2323 #include "Streams/MappedInFile.h"
2424 #include "Streams/StreamException.h"
2525
26-CLogFile::CLogFile(void)
26+CLogFile::CLogFile()
2727 {
28- m_maxlines = CRegStdDWORD(L"Software\\TortoiseSVN\\MaxLinesInLogfile", 4000);
28+ m_maxLines = CRegStdDWORD(L"Software\\TortoiseSVN\\MaxLinesInLogfile", 4000);
2929 }
3030
31-CLogFile::~CLogFile(void)
31+CLogFile::~CLogFile()
3232 {
3333 }
3434
@@ -40,10 +40,10 @@
4040
4141 bool CLogFile::Open(const CTSVNPath& logfile)
4242 {
43- if (m_maxlines == 0)
44- return false; // do nothing if no log lines should be used.
43+ if (m_maxLines == 0)
44+ return false; // do nothing if no log lines should be used.
4545 m_newLines.clear();
46- m_logfile = logfile;
46+ m_logFile = logfile;
4747 if (!logfile.Exists())
4848 {
4949 CPathUtils::MakeSureDirectoryPathExists(logfile.GetContainingDirectory().GetWinPath());
@@ -64,23 +64,23 @@
6464 {
6565 // limit log file growth
6666
67- size_t maxLines = (DWORD)m_maxlines;
67+ size_t maxLines = static_cast<DWORD>(m_maxLines);
6868 size_t newLines = m_newLines.size();
69- TrimFile (DWORD(max (maxLines, newLines) - newLines));
69+ TrimFile(static_cast<DWORD>(max(maxLines, newLines) - newLines));
7070
7171 // append new info
7272
7373 CStdioFile file;
7474
75- int retrycounter = 10;
75+ int retryCounter = 10;
7676 // try to open the file for about two seconds - some other TSVN process might be
7777 // writing to the file and we just wait a little for this to finish
78- while (!file.Open(m_logfile.GetWinPath(), CFile::typeText | CFile::modeReadWrite | CFile::modeCreate | CFile::modeNoTruncate) && retrycounter)
78+ while (!file.Open(m_logFile.GetWinPath(), CFile::typeText | CFile::modeReadWrite | CFile::modeCreate | CFile::modeNoTruncate) && retryCounter)
7979 {
80- retrycounter--;
80+ retryCounter--;
8181 Sleep(200);
8282 }
83- if (retrycounter == 0)
83+ if (retryCounter == 0)
8484 return false;
8585
8686 file.SeekToEnd();
@@ -106,19 +106,19 @@
106106 // first add an empty line as a separator
107107 m_newLines.push_back(sLine);
108108 // now add the time string
109- TCHAR datebuf[4096] = {0};
110- GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, datebuf, 4096);
111- sLine = datebuf;
112- GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, datebuf, 4096);
109+ TCHAR dateBuf[4096] = {0};
110+ GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, nullptr, nullptr, dateBuf, 4096);
111+ sLine = dateBuf;
112+ GetTimeFormat(LOCALE_USER_DEFAULT, 0, nullptr, nullptr, dateBuf, 4096);
113113 sLine += L" - ";
114- sLine += datebuf;
114+ sLine += dateBuf;
115115 m_newLines.push_back(sLine);
116116 return true;
117117 }
118118
119-void CLogFile::TrimFile (DWORD maxLines)
119+void CLogFile::TrimFile(DWORD maxLines) const
120120 {
121- if (!PathFileExists (m_logfile.GetWinPath()))
121+ if (!PathFileExists(m_logFile.GetWinPath()))
122122 return;
123123
124124 // find the start of the maxLines-th last line
@@ -126,10 +126,10 @@
126126
127127 try
128128 {
129- CMappedInFile file (m_logfile.GetWinPath(), true);
129+ CMappedInFile file(m_logFile.GetWinPath(), true);
130130
131131 unsigned char* begin = file.GetWritableBuffer();
132- unsigned char* end = begin + file.GetSize();
132+ unsigned char* end = begin + file.GetSize();
133133
134134 if (begin <= (end - 2))
135135 return;
@@ -157,8 +157,8 @@
157157 // remove data
158158
159159 size_t newSize = end - trimPos;
160- memmove (begin, trimPos, newSize);
161- file.Close (newSize);
160+ memmove(begin, trimPos, newSize);
161+ file.Close(newSize);
162162 }
163163 catch (CStreamException&)
164164 {
@@ -165,4 +165,3 @@
165165 // can't trim the file right now
166166 }
167167 }
168-
--- trunk/src/TortoiseProc/LogFile.h (revision 29186)
+++ trunk/src/TortoiseProc/LogFile.h (revision 29187)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2007-2008, 2010 - TortoiseSVN
3+// Copyright (C) 2007-2008, 2010, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -31,37 +31,36 @@
3131 class CLogFile
3232 {
3333 public:
34- CLogFile(void);
35- ~CLogFile(void);
34+ CLogFile();
35+ ~CLogFile();
3636
3737 /**
3838 * Opens the log file and reads its contents
3939 */
40- bool Open(const CTSVNPath& logfile);
40+ bool Open(const CTSVNPath& logfile);
4141 /**
4242 * Opens the default log file for TortoiseSVN and reads its contents
4343 */
44- bool Open();
44+ bool Open();
4545 /**
4646 * Adds one line to the log file. The file is \b not yet written back to disk.
4747 */
48- bool AddLine(const CString& line);
48+ bool AddLine(const CString& line);
4949 /**
5050 * Writes the contents to the disk.
5151 */
52- bool Close();
52+ bool Close();
5353
5454 /**
5555 * Inserts a line with the current time and date to the log file.
5656 */
57- bool AddTimeLine();
57+ bool AddTimeLine();
5858
5959 protected:
60+ void TrimFile(DWORD maxLines) const;
6061
61- void TrimFile (DWORD maxLines);
62-
6362 private:
64- CRegStdDWORD m_maxlines;
65- CTSVNPath m_logfile;
66- std::deque<CString> m_newLines;
63+ CRegStdDWORD m_maxLines;
64+ CTSVNPath m_logFile;
65+ std::deque<CString> m_newLines;
6766 };
--- trunk/src/Utils/IInputValidator.h (revision 29186)
+++ trunk/src/Utils/IInputValidator.h (revision 29187)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2010, 2013 - TortoiseSVN
3+// Copyright (C) 2010, 2013, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -18,10 +18,10 @@
1818 //
1919 #pragma once
2020
21-
2221 class IInputValidator
2322 {
2423 public:
24+ virtual ~IInputValidator() = default;
2525 /**
2626 * Method is called to validate the user input, usually an edit control.
2727 * Return an empty string if the input is valid. If the input is not valid,
--- trunk/src/Utils/IconExtractor.cpp (revision 29186)
+++ trunk/src/Utils/IconExtractor.cpp (revision 29187)
@@ -1,7 +1,7 @@
11 // TortoiseSVN - a Windows shell extension for easy version control
22
3+// Copyright (C) 2010-2012, 2014-2015, 2021 - TortoiseSVN
34 // Copyright (C) 2018 - Sven Strickroth <email@cs-ware.de>
4-// Copyright (C) 2010-2012, 2014-2015 - TortoiseSVN
55
66 // This program is free software; you can redistribute it and/or
77 // modify it under the terms of the GNU General Public License
@@ -21,103 +21,102 @@
2121 #include "IconExtractor.h"
2222 #include "SmartHandle.h"
2323
24-#define WIDTHBYTES(bits) ((((bits) + 31)>>5)<<2)
24+#define WIDTHBYTES(bits) ((((bits) + 31) >> 5) << 2)
2525
2626 CIconExtractor::CIconExtractor()
2727 {
2828 }
2929
30-DWORD CIconExtractor::ExtractIcon(HINSTANCE hResource, LPCTSTR id, LPCTSTR TargetICON)
30+DWORD CIconExtractor::ExtractIcon(HINSTANCE hResource, LPCTSTR id, LPCTSTR targetIcon)
3131 {
32- LPICONRESOURCE lpIR = NULL;
33- HRSRC hRsrc = NULL;
34- HGLOBAL hGlobal = NULL;
35- LPMEMICONDIR lpIcon = NULL;
32+ LPICONRESOURCE lpIr = nullptr;
33+ HRSRC hRsrc = nullptr;
34+ HGLOBAL hGlobal = nullptr;
35+ LPMEMICONDIR lpIcon = nullptr;
3636
3737 // Find the group icon resource
3838 hRsrc = FindResource(hResource, id, RT_GROUP_ICON);
3939
40- if (hRsrc == NULL)
40+ if (hRsrc == nullptr)
4141 return GetLastError();
4242
43- if ((hGlobal = LoadResource(hResource, hRsrc)) == NULL)
43+ if ((hGlobal = LoadResource(hResource, hRsrc)) == nullptr)
4444 return GetLastError();
4545
46- if ((lpIcon = (LPMEMICONDIR)LockResource(hGlobal)) == NULL)
46+ if ((lpIcon = static_cast<LPMEMICONDIR>(LockResource(hGlobal))) == nullptr)
4747 return GetLastError();
4848
49- if ((lpIR = (LPICONRESOURCE) malloc(sizeof(ICONRESOURCE) + ((lpIcon->idCount-1) * sizeof(ICONIMAGE)))) == NULL)
49+ if ((lpIr = static_cast<LPICONRESOURCE>(malloc(sizeof(ICONRESOURCE) + ((lpIcon->idCount - 1) * sizeof(ICONIMAGE))))) == nullptr)
5050 return GetLastError();
51- SecureZeroMemory(lpIR, sizeof(ICONRESOURCE) + ((lpIcon->idCount - 1) * sizeof(ICONIMAGE)));
52- lpIR->nNumImages = lpIcon->idCount;
51+ SecureZeroMemory(lpIr, sizeof(ICONRESOURCE) + ((lpIcon->idCount - 1) * sizeof(ICONIMAGE)));
52+ lpIr->nNumImages = lpIcon->idCount;
5353 OnOutOfScope(
54- for (UINT i = 0; i < lpIR->nNumImages; ++i)
55- free(lpIR->IconImages[i].lpBits);
56- free(lpIR);
57- );
54+ for (UINT i = 0; i < lpIr->nNumImages; ++i)
55+ free(lpIr->IconImages[i].lpBits);
56+ free(lpIr););
5857
5958 // Go through all the icons
60- for (UINT i = 0; i < lpIR->nNumImages; ++i)
59+ for (UINT i = 0; i < lpIr->nNumImages; ++i)
6160 {
6261 // Get the individual icon
63- if ((hRsrc = FindResource(hResource, MAKEINTRESOURCE(lpIcon->idEntries[i].nID), RT_ICON )) == NULL)
62+ if ((hRsrc = FindResource(hResource, MAKEINTRESOURCE(lpIcon->idEntries[i].nID), RT_ICON)) == nullptr)
6463 return GetLastError();
6564
66- if ((hGlobal = LoadResource(hResource, hRsrc )) == NULL)
65+ if ((hGlobal = LoadResource(hResource, hRsrc)) == nullptr)
6766 return GetLastError();
6867
6968 // Store a copy of the resource locally
70- lpIR->IconImages[i].dwNumBytes = SizeofResource(hResource, hRsrc);
71- lpIR->IconImages[i].lpBits =(LPBYTE) malloc(lpIR->IconImages[i].dwNumBytes);
72- if (lpIR->IconImages[i].lpBits == NULL)
69+ lpIr->IconImages[i].dwNumBytes = SizeofResource(hResource, hRsrc);
70+ lpIr->IconImages[i].lpBits = static_cast<LPBYTE>(malloc(lpIr->IconImages[i].dwNumBytes));
71+ if (lpIr->IconImages[i].lpBits == nullptr)
7372 return GetLastError();
7473
75- memcpy(lpIR->IconImages[i].lpBits, LockResource(hGlobal), lpIR->IconImages[i].dwNumBytes);
74+ memcpy(lpIr->IconImages[i].lpBits, LockResource(hGlobal), lpIr->IconImages[i].dwNumBytes);
7675
7776 // Adjust internal pointers
78- if (!AdjustIconImagePointers(&(lpIR->IconImages[i])))
77+ if (!AdjustIconImagePointers(&(lpIr->IconImages[i])))
7978 return GetLastError();
8079 }
8180
82- return WriteIconToICOFile(lpIR,TargetICON);
81+ return WriteIconToICOFile(lpIr, targetIcon);
8382 }
8483
85-DWORD CIconExtractor::WriteIconToICOFile(LPICONRESOURCE lpIR, LPCTSTR szFileName)
84+DWORD CIconExtractor::WriteIconToICOFile(LPICONRESOURCE lpIr, LPCTSTR szFileName)
8685 {
87- DWORD dwBytesWritten = 0;
86+ DWORD dwBytesWritten = 0;
8887
89- CAutoFile hFile = CreateFile(szFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
88+ CAutoFile hFile = CreateFile(szFileName, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
9089 // open the file
9190 if (!hFile)
9291 return GetLastError();
9392
9493 // Write the header
95- if (WriteICOHeader(hFile, lpIR->nNumImages))
94+ if (WriteICOHeader(hFile, lpIr->nNumImages))
9695 return GetLastError();
9796
9897 // Write the ICONDIRENTRY's
99- for (UINT i = 0; i < lpIR->nNumImages; ++i)
98+ for (UINT i = 0; i < lpIr->nNumImages; ++i)
10099 {
101- ICONDIRENTRY ide;
100+ ICONDIRENTRY ide;
102101
103102 // Convert internal format to ICONDIRENTRY
104- ide.bWidth = (BYTE)lpIR->IconImages[i].Width;
105- ide.bHeight = (BYTE)lpIR->IconImages[i].Height;
103+ ide.bWidth = static_cast<BYTE>(lpIr->IconImages[i].Width);
104+ ide.bHeight = static_cast<BYTE>(lpIr->IconImages[i].Height);
106105 if (ide.bHeight == 0) // 256x256 icon, both width and height must be 0
107- ide.bWidth = 0;
108- ide.bReserved = 0;
109- ide.wPlanes = lpIR->IconImages[i].lpbi->bmiHeader.biPlanes;
110- ide.wBitCount = lpIR->IconImages[i].lpbi->bmiHeader.biBitCount;
106+ ide.bWidth = 0;
107+ ide.bReserved = 0;
108+ ide.wPlanes = lpIr->IconImages[i].lpbi->bmiHeader.biPlanes;
109+ ide.wBitCount = lpIr->IconImages[i].lpbi->bmiHeader.biBitCount;
111110
112111 if ((ide.wPlanes * ide.wBitCount) >= 8)
113112 ide.bColorCount = 0;
114113 else
115114 ide.bColorCount = 1 << (ide.wPlanes * ide.wBitCount);
116- ide.dwBytesInRes = lpIR->IconImages[i].dwNumBytes;
117- ide.dwImageOffset = CalculateImageOffset( lpIR, i );
115+ ide.dwBytesInRes = lpIr->IconImages[i].dwNumBytes;
116+ ide.dwImageOffset = CalculateImageOffset(lpIr, i);
118117
119118 // Write the ICONDIRENTRY to disk
120- if (!WriteFile(hFile, &ide, sizeof(ICONDIRENTRY), &dwBytesWritten, NULL))
119+ if (!WriteFile(hFile, &ide, sizeof(ICONDIRENTRY), &dwBytesWritten, nullptr))
121120 return GetLastError();
122121
123122 if (dwBytesWritten != sizeof(ICONDIRENTRY))
@@ -125,22 +124,22 @@
125124 }
126125
127126 // Write the image bits for each image
128- for (UINT i = 0; i < lpIR->nNumImages; ++i)
127+ for (UINT i = 0; i < lpIr->nNumImages; ++i)
129128 {
130- DWORD dwTemp = lpIR->IconImages[i].lpbi->bmiHeader.biSizeImage;
131- bool bError = false; // fix size even on error
129+ DWORD dwTemp = lpIr->IconImages[i].lpbi->bmiHeader.biSizeImage;
130+ bool bError = false; // fix size even on error
132131
133132 // Set the sizeimage member to zero, but not if the icon is PNG
134- if (lpIR->IconImages[i].lpbi->bmiHeader.biCompression != 65536)
135- lpIR->IconImages[i].lpbi->bmiHeader.biSizeImage = 0;
136- if (!WriteFile( hFile, lpIR->IconImages[i].lpBits, lpIR->IconImages[i].dwNumBytes, &dwBytesWritten, NULL))
133+ if (lpIr->IconImages[i].lpbi->bmiHeader.biCompression != 65536)
134+ lpIr->IconImages[i].lpbi->bmiHeader.biSizeImage = 0;
135+ if (!WriteFile(hFile, lpIr->IconImages[i].lpBits, lpIr->IconImages[i].dwNumBytes, &dwBytesWritten, nullptr))
137136 bError = true;
138137
139- if (dwBytesWritten != lpIR->IconImages[i].dwNumBytes)
138+ if (dwBytesWritten != lpIr->IconImages[i].dwNumBytes)
140139 bError = true;
141140
142141 // set it back
143- lpIR->IconImages[i].lpbi->bmiHeader.biSizeImage = dwTemp;
142+ lpIr->IconImages[i].lpbi->bmiHeader.biSizeImage = dwTemp;
144143 if (bError)
145144 return GetLastError();
146145 }
@@ -147,42 +146,40 @@
147146 return NO_ERROR;
148147 }
149148
150-DWORD CIconExtractor::CalculateImageOffset(LPICONRESOURCE lpIR, UINT nIndex) const
149+DWORD CIconExtractor::CalculateImageOffset(LPICONRESOURCE lpIr, UINT nIndex)
151150 {
152- DWORD dwSize;
153-
154151 // Calculate the ICO header size
155- dwSize = 3 * sizeof(WORD);
152+ DWORD dwSize = 3 * sizeof(WORD);
156153 // Add the ICONDIRENTRY's
157- dwSize += lpIR->nNumImages * sizeof(ICONDIRENTRY);
154+ dwSize += lpIr->nNumImages * sizeof(ICONDIRENTRY);
158155 // Add the sizes of the previous images
159- for(UINT i = 0; i < nIndex; ++i)
160- dwSize += lpIR->IconImages[i].dwNumBytes;
156+ for (UINT i = 0; i < nIndex; ++i)
157+ dwSize += lpIr->IconImages[i].dwNumBytes;
161158
162159 return dwSize;
163160 }
164161
165-DWORD CIconExtractor::WriteICOHeader(HANDLE hFile, UINT nNumEntries) const
162+DWORD CIconExtractor::WriteICOHeader(HANDLE hFile, UINT nNumEntries)
166163 {
167- WORD Output = 0;
168- DWORD dwBytesWritten = 0;
164+ WORD output = 0;
165+ DWORD dwBytesWritten = 0;
169166
170167 // Write 'reserved' WORD
171- if (!WriteFile( hFile, &Output, sizeof(WORD), &dwBytesWritten, NULL))
168+ if (!WriteFile(hFile, &output, sizeof(WORD), &dwBytesWritten, nullptr))
172169 return GetLastError();
173170 // Did we write a WORD?
174171 if (dwBytesWritten != sizeof(WORD))
175172 return GetLastError();
176173 // Write 'type' WORD (1)
177- Output = 1;
178- if (!WriteFile( hFile, &Output, sizeof(WORD), &dwBytesWritten, NULL))
174+ output = 1;
175+ if (!WriteFile(hFile, &output, sizeof(WORD), &dwBytesWritten, nullptr))
179176 return GetLastError();
180177 // Did we write a WORD?
181178 if (dwBytesWritten != sizeof(WORD))
182179 return GetLastError();
183180 // Write Number of Entries
184- Output = (WORD)nNumEntries;
185- if (!WriteFile(hFile, &Output, sizeof(WORD), &dwBytesWritten, NULL))
181+ output = static_cast<WORD>(nNumEntries);
182+ if (!WriteFile(hFile, &output, sizeof(WORD), &dwBytesWritten, nullptr))
186183 return GetLastError();
187184 // Did we write a WORD?
188185 if (dwBytesWritten != sizeof(WORD))
@@ -193,21 +190,21 @@
193190
194191 BOOL CIconExtractor::AdjustIconImagePointers(LPICONIMAGE lpImage)
195192 {
196- if (lpImage == NULL)
193+ if (lpImage == nullptr)
197194 return FALSE;
198195
199196 // BITMAPINFO is at beginning of bits
200- lpImage->lpbi = (LPBITMAPINFO)lpImage->lpBits;
197+ lpImage->lpbi = reinterpret_cast<LPBITMAPINFO>(lpImage->lpBits);
201198 // Width - simple enough
202199 lpImage->Width = lpImage->lpbi->bmiHeader.biWidth;
203200 // Icons are stored in funky format where height is doubled - account for it
204- lpImage->Height = (lpImage->lpbi->bmiHeader.biHeight)/2;
201+ lpImage->Height = (lpImage->lpbi->bmiHeader.biHeight) / 2;
205202 // How many colors?
206203 lpImage->Colors = lpImage->lpbi->bmiHeader.biPlanes * lpImage->lpbi->bmiHeader.biBitCount;
207204 // XOR bits follow the header and color table
208- lpImage->lpXOR = (PBYTE)FindDIBBits((LPSTR)lpImage->lpbi);
205+ lpImage->lpXOR = reinterpret_cast<PBYTE>(FindDIBBits(reinterpret_cast<LPSTR>(lpImage->lpbi)));
209206 // AND bits follow the XOR bits
210- lpImage->lpAND = lpImage->lpXOR + (lpImage->Height*BytesPerLine((LPBITMAPINFOHEADER)(lpImage->lpbi)));
207+ lpImage->lpAND = lpImage->lpXOR + (lpImage->Height * BytesPerLine(reinterpret_cast<LPBITMAPINFOHEADER>(lpImage->lpbi)));
211208
212209 return TRUE;
213210 }
@@ -214,7 +211,7 @@
214211
215212 LPSTR CIconExtractor::FindDIBBits(LPSTR lpbi)
216213 {
217- return (lpbi + *(LPDWORD)lpbi + PaletteSize(lpbi));
214+ return (lpbi + *reinterpret_cast<LPDWORD>(lpbi) + PaletteSize(lpbi));
218215 }
219216
220217 WORD CIconExtractor::PaletteSize(LPSTR lpbi)
@@ -222,30 +219,30 @@
222219 return (DIBNumColors(lpbi) * sizeof(RGBQUAD));
223220 }
224221
225-DWORD CIconExtractor::BytesPerLine(LPBITMAPINFOHEADER lpBMIH) const
222+DWORD CIconExtractor::BytesPerLine(LPBITMAPINFOHEADER lpBmih)
226223 {
227- return WIDTHBYTES(lpBMIH->biWidth * lpBMIH->biPlanes * lpBMIH->biBitCount);
224+ return WIDTHBYTES(lpBmih->biWidth * lpBmih->biPlanes * lpBmih->biBitCount);
228225 }
229226
230-WORD CIconExtractor::DIBNumColors(LPSTR lpbi) const
227+WORD CIconExtractor::DIBNumColors(LPSTR lpbi)
231228 {
232- WORD wBitCount;
233- DWORD dwClrUsed;
229+ DWORD dwClrUsed = reinterpret_cast<LPBITMAPINFOHEADER>(lpbi)->biClrUsed;
234230
235- dwClrUsed = ((LPBITMAPINFOHEADER) lpbi)->biClrUsed;
236-
237231 if (dwClrUsed)
238- return (WORD) dwClrUsed;
232+ return static_cast<WORD>(dwClrUsed);
239233
240- wBitCount = ((LPBITMAPINFOHEADER) lpbi)->biBitCount;
234+ WORD wBitCount = reinterpret_cast<LPBITMAPINFOHEADER>(lpbi)->biBitCount;
241235
242236 switch (wBitCount)
243237 {
244- case 1: return 2;
245- case 4: return 16;
246- case 8: return 256;
247- default:return 0;
238+ case 1:
239+ return 2;
240+ case 4:
241+ return 16;
242+ case 8:
243+ return 256;
244+ default:
245+ return 0;
248246 }
249247 //return 0;
250248 }
251-
--- trunk/src/Utils/IconExtractor.h (revision 29186)
+++ trunk/src/Utils/IconExtractor.h (revision 29187)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2010, 2014 - TortoiseSVN
3+// Copyright (C) 2010, 2014, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -18,20 +18,20 @@
1818 //
1919 #pragma once
2020
21-
2221 // The following structures are taken from iconpro sdk example
23-#pragma pack( push )
24-#pragma pack( 2 )
22+#pragma pack(push)
23+#pragma pack(2)
24+// ReSharper disable CppInconsistentNaming
2525 typedef struct
2626 {
27- BYTE bWidth; // Width of the image
28- BYTE bHeight; // Height of the image (times 2)
29- BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
30- BYTE bReserved; // Reserved
31- WORD wPlanes; // Color Planes
32- WORD wBitCount; // Bits per pixel
33- DWORD dwBytesInRes; // how many bytes in this resource?
34- WORD nID; // the ID
27+ BYTE bWidth; // Width of the image
28+ BYTE bHeight; // Height of the image (times 2)
29+ BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
30+ BYTE bReserved; // Reserved
31+ WORD wPlanes; // Color Planes
32+ WORD wBitCount; // Bits per pixel
33+ DWORD dwBytesInRes; // how many bytes in this resource?
34+ WORD nID; // the ID
3535 } MEMICONDIRENTRY, *LPMEMICONDIRENTRY;
3636 typedef struct
3737 {
@@ -40,46 +40,46 @@
4040 WORD idCount; // how many images?
4141 MEMICONDIRENTRY idEntries[1]; // the entries for each image
4242 } MEMICONDIR, *LPMEMICONDIR;
43-#pragma pack( pop )
43+#pragma pack(pop)
4444
4545 typedef struct
4646 {
47- UINT Width, Height, Colors; // Width, Height and bpp
48- LPBYTE lpBits; // ptr to DIB bits
49- DWORD dwNumBytes; // how many bytes?
50- LPBITMAPINFO lpbi; // ptr to header
51- LPBYTE lpXOR; // ptr to XOR image bits
52- LPBYTE lpAND; // ptr to AND image bits
47+ UINT Width, Height, Colors; // Width, Height and bpp
48+ LPBYTE lpBits; // ptr to DIB bits
49+ DWORD dwNumBytes; // how many bytes?
50+ LPBITMAPINFO lpbi; // ptr to header
51+ LPBYTE lpXOR; // ptr to XOR image bits
52+ LPBYTE lpAND; // ptr to AND image bits
5353 } ICONIMAGE, *LPICONIMAGE;
5454 typedef struct
5555 {
56- BOOL bHasChanged; // Has image changed?
57- UINT nNumImages; // How many images?
58- ICONIMAGE IconImages[1]; // Image entries
56+ BOOL bHasChanged; // Has image changed?
57+ UINT nNumImages; // How many images?
58+ ICONIMAGE IconImages[1]; // Image entries
5959 } ICONRESOURCE, *LPICONRESOURCE;
6060
61-
6261 // These next two structs represent how the icon information is stored
6362 // in an ICO file.
6463 typedef struct
6564 {
66- BYTE bWidth; // Width of the image
67- BYTE bHeight; // Height of the image (times 2)
68- BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
69- BYTE bReserved; // Reserved
70- WORD wPlanes; // Color Planes
71- WORD wBitCount; // Bits per pixel
72- DWORD dwBytesInRes; // how many bytes in this resource?
73- DWORD dwImageOffset; // where in the file is this image
65+ BYTE bWidth; // Width of the image
66+ BYTE bHeight; // Height of the image (times 2)
67+ BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
68+ BYTE bReserved; // Reserved
69+ WORD wPlanes; // Color Planes
70+ WORD wBitCount; // Bits per pixel
71+ DWORD dwBytesInRes; // how many bytes in this resource?
72+ DWORD dwImageOffset; // where in the file is this image
7473 } ICONDIRENTRY, *LPICONDIRENTRY;
7574 typedef struct
7675 {
77- WORD idReserved; // Reserved
78- WORD idType; // resource type (1 for icons)
79- WORD idCount; // how many images?
80- ICONDIRENTRY idEntries[1]; // the entries for each image
76+ WORD idReserved; // Reserved
77+ WORD idType; // resource type (1 for icons)
78+ WORD idCount; // how many images?
79+ ICONDIRENTRY idEntries[1]; // the entries for each image
8180 } ICONDIR, *LPICONDIR;
8281
82+// ReSharper restore CppInconsistentNaming
8383
8484 class CIconExtractor
8585 {
@@ -86,17 +86,16 @@
8686 public:
8787 CIconExtractor();
8888
89- DWORD ExtractIcon(HINSTANCE hResource, LPCTSTR id, LPCTSTR TargetICON);
89+ static DWORD ExtractIcon(HINSTANCE hResource, LPCTSTR id, LPCTSTR targetIcon);
9090
9191 private:
92- DWORD WriteIconToICOFile(LPICONRESOURCE lpIR, LPCTSTR szFileName);
93- BOOL AdjustIconImagePointers(LPICONIMAGE lpImage);
92+ static DWORD WriteIconToICOFile(LPICONRESOURCE lpIr, LPCTSTR szFileName);
93+ static BOOL AdjustIconImagePointers(LPICONIMAGE lpImage);
9494
95- LPSTR FindDIBBits(LPSTR lpbi);
96- WORD DIBNumColors(LPSTR lpbi) const;
97- WORD PaletteSize(LPSTR lpbi);
98- DWORD BytesPerLine(LPBITMAPINFOHEADER lpBMIH) const;
99- DWORD WriteICOHeader(HANDLE hFile, UINT nNumEntries) const;
100- DWORD CalculateImageOffset(LPICONRESOURCE lpIR, UINT nIndex) const;
95+ static LPSTR FindDIBBits(LPSTR lpbi);
96+ static WORD DIBNumColors(LPSTR lpbi);
97+ static WORD PaletteSize(LPSTR lpbi);
98+ static DWORD BytesPerLine(LPBITMAPINFOHEADER lpBmih);
99+ static DWORD WriteICOHeader(HANDLE hFile, UINT nNumEntries);
100+ static DWORD CalculateImageOffset(LPICONRESOURCE lpIr, UINT nIndex);
101101 };
102-
--- trunk/src/Utils/JumpListHelpers.cpp (revision 29186)
+++ trunk/src/Utils/JumpListHelpers.cpp (revision 29187)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2009-2014 - TortoiseSVN
3+// Copyright (C) 2009-2014, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -25,12 +25,12 @@
2525
2626 HRESULT SetAppID(LPCTSTR appID)
2727 {
28- HRESULT hRes = S_FALSE;
29- typedef HRESULT STDAPICALLTYPE SetCurrentProcessExplicitAppUserModelIDFN(PCWSTR AppID);
30- CAutoLibrary hShell = AtlLoadSystemLibraryUsingFullPath(L"shell32.dll");
28+ HRESULT hRes = S_FALSE;
29+ using SetCurrentProcessExplicitAppUserModelIdfn = HRESULT STDAPICALLTYPE(PCWSTR appId);
30+ CAutoLibrary hShell = AtlLoadSystemLibraryUsingFullPath(L"shell32.dll");
3131 if (hShell)
3232 {
33- SetCurrentProcessExplicitAppUserModelIDFN *pfnSetCurrentProcessExplicitAppUserModelID = (SetCurrentProcessExplicitAppUserModelIDFN*)GetProcAddress(hShell, "SetCurrentProcessExplicitAppUserModelID");
33+ SetCurrentProcessExplicitAppUserModelIdfn *pfnSetCurrentProcessExplicitAppUserModelID = reinterpret_cast<SetCurrentProcessExplicitAppUserModelIdfn *>(GetProcAddress(hShell, "SetCurrentProcessExplicitAppUserModelID"));
3434 if (pfnSetCurrentProcessExplicitAppUserModelID)
3535 {
3636 hRes = pfnSetCurrentProcessExplicitAppUserModelID(appID);
@@ -42,12 +42,12 @@
4242 HRESULT CreateShellLink(PCWSTR pszArguments, PCWSTR pszTitle, int iconIndex, IShellLink **ppsl)
4343 {
4444 ATL::CComPtr<IShellLink> psl;
45- HRESULT hr = psl.CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER);
45+ HRESULT hr = psl.CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER);
4646 if (FAILED(hr))
4747 return hr;
4848
49- WCHAR szAppPath[MAX_PATH] = { 0 };
50- if (GetModuleFileName(NULL, szAppPath, _countof(szAppPath)) == 0)
49+ WCHAR szAppPath[MAX_PATH] = {0};
50+ if (GetModuleFileName(nullptr, szAppPath, _countof(szAppPath)) == 0)
5151 {
5252 hr = HRESULT_FROM_WIN32(GetLastError());
5353 return hr;
@@ -69,11 +69,11 @@
6969 if (FAILED(hr))
7070 return hr;
7171
72- PROPVARIANT propvar;
73- hr = InitPropVariantFromString(pszTitle, &propvar);
72+ PROPVARIANT propVar;
73+ hr = InitPropVariantFromString(pszTitle, &propVar);
7474 if (SUCCEEDED(hr))
7575 {
76- hr = pps->SetValue(PKEY_Title, propvar);
76+ hr = pps->SetValue(PKEY_Title, propVar);
7777 if (SUCCEEDED(hr))
7878 {
7979 hr = pps->Commit();
@@ -82,7 +82,7 @@
8282 hr = psl.QueryInterface(ppsl);
8383 }
8484 }
85- PropVariantClear(&propvar);
85+ PropVariantClear(&propVar);
8686 }
8787 return hr;
8888 }
@@ -90,16 +90,16 @@
9090 HRESULT CreateSeparatorLink(IShellLink **ppsl)
9191 {
9292 ATL::CComPtr<IPropertyStore> pps;
93- HRESULT hr = pps.CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER);
93+ HRESULT hr = pps.CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER);
9494 if (FAILED(hr))
9595 return hr;
9696
97- PROPVARIANT propvar;
98- hr = InitPropVariantFromBoolean(TRUE, &propvar);
97+ PROPVARIANT propVar;
98+ hr = InitPropVariantFromBoolean(TRUE, &propVar);
9999 if (FAILED(hr))
100100 return hr;
101101
102- hr = pps->SetValue(PKEY_AppUserModel_IsDestListSeparator, propvar);
102+ hr = pps->SetValue(PKEY_AppUserModel_IsDestListSeparator, propVar);
103103 if (SUCCEEDED(hr))
104104 {
105105 hr = pps->Commit();
@@ -108,13 +108,12 @@
108108 hr = pps.QueryInterface(ppsl);
109109 }
110110 }
111- PropVariantClear(&propvar);
111+ PropVariantClear(&propVar);
112112 return hr;
113113 }
114114
115115 bool IsItemInArray(IShellItem *psi, IObjectArray *poaRemoved)
116116 {
117-
118117 UINT cItems;
119118 if (FAILED(poaRemoved->GetCount(&cItems)))
120119 return false;
@@ -134,7 +133,7 @@
134133 void DeleteJumpList(LPCTSTR appID)
135134 {
136135 ATL::CComPtr<ICustomDestinationList> pcdl;
137- HRESULT hr = pcdl.CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER);
136+ HRESULT hr = pcdl.CoCreateInstance(CLSID_DestinationList, nullptr, CLSCTX_INPROC_SERVER);
138137 if (SUCCEEDED(hr))
139138 {
140139 pcdl->DeleteList(appID);
--- trunk/src/Utils/Libraries.cpp (revision 29186)
+++ trunk/src/Utils/Libraries.cpp (revision 29187)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2010-2016 - TortoiseSVN
3+// Copyright (C) 2010-2016, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -20,24 +20,23 @@
2020 #include "Libraries.h"
2121 #include "PathUtils.h"
2222 #include "resource.h"
23-#include "SmartHandle.h"
2423 #include <initguid.h>
25-#include <propkeydef.h>
2624 #include <VersionHelpers.h>
2725
28-
2926 #ifdef _WIN64
30-DEFINE_GUID(FOLDERTYPEID_SVNWC, 0xC1D29ED1, 0xCC8B, 0x4790, 0xA3, 0x45, 0xEC, 0x87, 0xDE, 0x96, 0xE9, 0x76);
31-DEFINE_GUID(FOLDERTYPEID_SVNWC32, 0x72949A62, 0x135C, 0x4681, 0x88, 0x7C, 0x1C, 0x19, 0x49, 0x76, 0x83, 0x37);
27+DEFINE_GUID(FOLDERTYPEID_SVNWC, 0xC1D29ED1, 0xCC8B, 0x4790, 0xA3, 0x45, 0xEC, 0x87, 0xDE, 0x96, 0xE9, 0x76);
28+DEFINE_GUID(FOLDERTYPEID_SVNWC32, 0x72949A62, 0x135C, 0x4681, 0x88, 0x7C, 0x1C, 0x19, 0x49, 0x76, 0x83, 0x37);
3229 #else
33-DEFINE_GUID(FOLDERTYPEID_SVNWC, 0x72949A62, 0x135C, 0x4681, 0x88, 0x7C, 0x1C, 0x19, 0x49, 0x76, 0x83, 0x37);
30+DEFINE_GUID(FOLDERTYPEID_SVNWC, 0x72949A62, 0x135C, 0x4681, 0x88, 0x7C, 0x1C, 0x19, 0x49, 0x76, 0x83, 0x37);
3431 #endif
3532 #ifndef _WIN32_WINNT_WIN10
36-#define _WIN32_WINNT_WIN10 0x0A00
33+# define _WIN32_WINNT_WIN10 0x0A00
3734 #endif
38-bool IsWin10OrLater() { return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN10), LOBYTE(_WIN32_WINNT_WIN10), 0); }
35+bool IsWin10OrLater()
36+{
37+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN10), LOBYTE(_WIN32_WINNT_WIN10), 0);
38+}
3939
40-
4140 /**
4241 * Makes sure a library named "Subversion" exists and has our template
4342 * set to it.
@@ -54,7 +53,7 @@
5453 if (bIsWow64)
5554 return;
5655
57- CComPtr<IShellLibrary> pLibrary = NULL;
56+ CComPtr<IShellLibrary> pLibrary = nullptr;
5857 if (FAILED(OpenShellLibrary(L"Subversion", &pLibrary)))
5958 {
6059 if (!bCreate)
@@ -63,7 +62,7 @@
6362 return;
6463
6564 // Save the new library under the user's Libraries folder.
66- CComPtr<IShellItem> pSavedTo = NULL;
65+ CComPtr<IShellItem> pSavedTo = nullptr;
6766 if (FAILED(pLibrary->SaveInKnownFolder(FOLDERID_UsersLibraries, L"Subversion", LSF_OVERRIDEEXISTING, &pSavedTo)))
6867 return;
6968 }
@@ -75,12 +74,12 @@
7574 CString appDir = CPathUtils::GetAppDirectory();
7675 if (appDir.GetLength() < MAX_PATH)
7776 {
78- TCHAR buf[MAX_PATH] = {0};
79- PathCanonicalize(buf, (LPCTSTR)appDir);
77+ wchar_t buf[MAX_PATH] = {0};
78+ PathCanonicalize(buf, static_cast<LPCWSTR>(appDir));
8079 appDir = buf;
8180 }
82- path.Format(L"%s%s,-%d", (LPCTSTR)appDir, L"TortoiseProc.exe", IsWin10OrLater() ? IDI_LIBRARY_WIN10 : IDI_LIBRARY);
83- pLibrary->SetIcon((LPCTSTR)path);
81+ path.Format(L"%s%s,-%d", static_cast<LPCWSTR>(appDir), L"TortoiseProc.exe", IsWin10OrLater() ? IDI_LIBRARY_WIN10 : IDI_LIBRARY);
82+ pLibrary->SetIcon(static_cast<LPCWSTR>(path));
8483 pLibrary->Commit();
8584 }
8685 }
@@ -100,11 +99,10 @@
10099 */
101100 HRESULT OpenShellLibrary(LPWSTR pwszLibraryName, IShellLibrary** ppShellLib)
102101 {
103- HRESULT hr;
104- *ppShellLib = NULL;
102+ *ppShellLib = nullptr;
105103
106- CComPtr<IShellItem2> pShellItem = NULL;
107- hr = GetShellLibraryItem(pwszLibraryName, &pShellItem);
104+ CComPtr<IShellItem2> pShellItem = nullptr;
105+ HRESULT hr = GetShellLibraryItem(pwszLibraryName, &pShellItem);
108106 if (FAILED(hr))
109107 return hr;
110108
@@ -128,11 +126,11 @@
128126 */
129127 HRESULT GetShellLibraryItem(LPWSTR pwszLibraryName, IShellItem2** ppShellItem)
130128 {
131- HRESULT hr = E_NOINTERFACE;
132- *ppShellItem = NULL;
129+ HRESULT hr = E_NOINTERFACE;
130+ *ppShellItem = nullptr;
133131
134132 // Create the real library file name
135- WCHAR wszRealLibraryName[MAX_PATH] = { 0 };
133+ WCHAR wszRealLibraryName[MAX_PATH] = {0};
136134 swprintf_s(wszRealLibraryName, L"%s%s", pwszLibraryName, L".library-ms");
137135
138136 hr = SHCreateItemInKnownFolder(FOLDERID_UsersLibraries, KF_FLAG_DEFAULT_PATH | KF_FLAG_NO_ALIAS, wszRealLibraryName, IID_PPV_ARGS(ppShellItem));
--- trunk/src/Utils/ListViewAccServer.cpp (revision 29186)
+++ trunk/src/Utils/ListViewAccServer.cpp (revision 29187)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2009-2013, 2015 - TortoiseSVN
3+// Copyright (C) 2009-2013, 2015, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -21,11 +21,11 @@
2121
2222 STDMETHODIMP ListViewAccServer::QueryInterface(REFIID riid, void** ppvObject)
2323 {
24- if (ppvObject == 0)
24+ if (ppvObject == nullptr)
2525 return E_POINTER;
26- *ppvObject = NULL;
26+ *ppvObject = nullptr;
2727 if (IsEqualIID(IID_IUnknown, riid) || IsEqualIID(IID_IAccPropServer, riid))
28- *ppvObject=static_cast<IAccPropServer*>(this);
28+ *ppvObject = static_cast<IAccPropServer*>(this);
2929 else
3030 return E_NOINTERFACE;
3131
@@ -33,42 +33,44 @@
3333 return S_OK;
3434 }
3535
36-STDMETHODIMP_(ULONG) ListViewAccServer::AddRef(void)
36+STDMETHODIMP_(ULONG)
37+ListViewAccServer::AddRef()
3738 {
38- return ++m_Ref;
39+ return ++m_ref;
3940 }
4041
41-STDMETHODIMP_(ULONG) ListViewAccServer::Release(void)
42+STDMETHODIMP_(ULONG)
43+ListViewAccServer::Release()
4244 {
43- --m_Ref;
44- return m_Ref;
45+ --m_ref;
46+ return m_ref;
4547 }
4648
4749 HRESULT STDMETHODCALLTYPE ListViewAccServer::GetPropValue(
48- const BYTE * pIDString,
49- DWORD dwIDStringLen,
50- MSAAPROPID /*idProp*/,
51- VARIANT * pvarValue,
52- BOOL * pfGotProp )
50+ const BYTE* pIDString,
51+ DWORD dwIDStringLen,
52+ MSAAPROPID /*idProp*/,
53+ VARIANT* pvarValue,
54+ BOOL* pfGotProp)
5355 {
54- if(pfGotProp == 0)
56+ if (pfGotProp == nullptr)
5557 return E_POINTER;
5658
57- // Default return values, in case we need to bail out…
58- *pfGotProp = FALSE;
59+ // Default return values, in case we need to bail out…
60+ *pfGotProp = FALSE;
5961 pvarValue->vt = VT_EMPTY;
60- // Extract the idChild from the identity string…
61- DWORD idObject, idChild;
62- HWND dwHcontrol;
63- HRESULT hr = m_pAccPropSvc->DecomposeHwndIdentityString(pIDString, dwIDStringLen, &dwHcontrol, &idObject, &idChild);
62+ // Extract the idChild from the identity string…
63+ DWORD idObject = 0, idChild = 0;
64+ HWND dwHcontrol = nullptr;
65+ HRESULT hr = m_pAccPropSvc->DecomposeHwndIdentityString(pIDString, dwIDStringLen, &dwHcontrol, &idObject, &idChild);
6466 if (hr != S_OK)
6567 {
6668 return S_OK;
6769 }
6870
69- HWND Hwnd = dwHcontrol;
71+ HWND hwnd = dwHcontrol;
7072 // Only supply help string for child elements, not the
71- // listview itself…
73+ // listview itself…
7274 if (idChild == CHILDID_SELF)
7375 {
7476 return S_OK;
@@ -76,46 +78,46 @@
7678
7779 // GetHelpString returns a UNICODE string corresponding to
7880 // the index it is passed.
79- CString sHelpString = m_pAccProvider->GetListviewHelpString(Hwnd, idChild - 1);
81+ CString sHelpString = m_pAccProvider->GetListviewHelpString(hwnd, idChild - 1);
8082 if (sHelpString.IsEmpty())
8183 {
8284 return S_OK;
8385 }
8486
85- BSTR bstr = SysAllocString((LPCTSTR)sHelpString);
86- pvarValue->vt = VT_BSTR;
87- pvarValue->bstrVal = bstr;
88- *pfGotProp = TRUE;
87+ BSTR bStr = SysAllocString(static_cast<LPCWSTR>(sHelpString));
88+ pvarValue->vt = VT_BSTR;
89+ pvarValue->bstrVal = bStr;
90+ *pfGotProp = TRUE;
8991 return S_OK;
9092 }
9193
92-ListViewAccServer * ListViewAccServer::CreateProvider(HWND hControl, ListViewAccProvider * provider)
94+ListViewAccServer* ListViewAccServer::CreateProvider(HWND hControl, ListViewAccProvider* provider)
9395 {
9496 ATL::CComPtr<IAccPropServices> pAccPropSvc;
95- HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);
97+ HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, nullptr, CLSCTX_SERVER);
9698 if (hr == S_OK && pAccPropSvc)
9799 {
98- ListViewAccServer * pLVServer = new (std::nothrow) ListViewAccServer(pAccPropSvc);
100+ ListViewAccServer* pLVServer = new (std::nothrow) ListViewAccServer(pAccPropSvc);
99101 if (pLVServer)
100102 {
101103 pLVServer->m_pAccProvider = provider;
102104
103105 MSAAPROPID propid = PROPID_ACC_HELP;
104- pAccPropSvc->SetHwndPropServer(hControl, (DWORD)OBJID_CLIENT, CHILDID_SELF, &propid, 1, pLVServer, ANNO_CONTAINER);
106+ pAccPropSvc->SetHwndPropServer(hControl, static_cast<DWORD>(OBJID_CLIENT), CHILDID_SELF, &propid, 1, pLVServer, ANNO_CONTAINER);
105107 pLVServer->Release();
106108 }
107109 return pLVServer;
108110 }
109- return NULL;
111+ return nullptr;
110112 }
111113
112-void ListViewAccServer::ClearProvider( HWND hControl )
114+void ListViewAccServer::ClearProvider(HWND hControl)
113115 {
114116 ATL::CComPtr<IAccPropServices> pAccPropSvc;
115- HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);
117+ HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, nullptr, CLSCTX_SERVER);
116118 if (hr == S_OK && pAccPropSvc)
117119 {
118- MSAAPROPID propid = PROPID_ACC_HELP;
119- pAccPropSvc->ClearHwndProps(hControl, (DWORD)OBJID_CLIENT, CHILDID_SELF, &propid, 1);
120+ MSAAPROPID propId = PROPID_ACC_HELP;
121+ pAccPropSvc->ClearHwndProps(hControl, static_cast<DWORD>(OBJID_CLIENT), CHILDID_SELF, &propId, 1);
120122 }
121123 }
--- trunk/src/Utils/ListViewAccServer.h (revision 29186)
+++ trunk/src/Utils/ListViewAccServer.h (revision 29187)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2009-2010, 2012 - TortoiseSVN
3+// Copyright (C) 2009-2010, 2012, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -26,6 +26,7 @@
2626 class ListViewAccProvider
2727 {
2828 public:
29+ virtual ~ListViewAccProvider() = default;
2930 /**
3031 * Called to retrieve the help string text.
3132 * \param hControl the HWND of the list view control
@@ -40,35 +41,35 @@
4041 * Use ListViewAccServer::CreateProvider() to create start the
4142 * callback.
4243 */
43-class ListViewAccServer: public IAccPropServer
44+class ListViewAccServer : public IAccPropServer
4445 {
4546 public:
46- ListViewAccServer(IAccPropServices * pAccPropSvc)
47- : m_Ref( 1 )
48- , m_pAccPropSvc( pAccPropSvc )
49- , m_pAccProvider( NULL )
47+ ListViewAccServer(IAccPropServices* pAccPropSvc)
48+ : m_ref(1)
49+ , m_pAccPropSvc(pAccPropSvc)
50+ , m_pAccProvider(nullptr)
5051 {
5152 m_pAccPropSvc->AddRef();
5253 }
5354
54- ~ListViewAccServer()
55+ virtual ~ListViewAccServer()
5556 {
5657 m_pAccPropSvc->Release();
5758 }
5859
59- static ListViewAccServer * CreateProvider(HWND hControl, ListViewAccProvider * provider);
60+ static ListViewAccServer* CreateProvider(HWND hControl, ListViewAccProvider* provider);
6061 /// must be called in the WM_DESTROY handler!
6162 static void ClearProvider(HWND hControl);
6263
63- HRESULT STDMETHODCALLTYPE GetPropValue(const BYTE * pIDString, DWORD dwIDStringLen, MSAAPROPID idProp, VARIANT * pvarValue, BOOL * pfGotProp);
64+ HRESULT STDMETHODCALLTYPE GetPropValue(const BYTE* pIDString, DWORD dwIDStringLen, MSAAPROPID idProp, VARIANT* pvarValue, BOOL* pfGotProp) override;
6465
6566 // IUnknown
66- virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
67- virtual ULONG STDMETHODCALLTYPE AddRef(void);
68- virtual ULONG STDMETHODCALLTYPE Release(void);
67+ HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) override;
68+ ULONG STDMETHODCALLTYPE AddRef() override;
69+ ULONG STDMETHODCALLTYPE Release() override;
6970
7071 private:
71- ULONG m_Ref;
72- IAccPropServices * m_pAccPropSvc;
73- ListViewAccProvider * m_pAccProvider;
72+ ULONG m_ref;
73+ IAccPropServices* m_pAccPropSvc;
74+ ListViewAccProvider* m_pAccProvider;
7475 };
--- trunk/src/Utils/LruCache.cpp (revision 29186)
+++ trunk/src/Utils/LruCache.cpp (revision 29187)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2016 - TortoiseSVN
3+// Copyright (C) 2016, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -21,7 +21,7 @@
2121 #include "LruCache.h"
2222
2323 #if defined(_DEBUG)
24-static class LruCacheTest
24+[[maybe_unused]] static class LruCacheTest
2525 {
2626 public:
2727 LruCacheTest()
@@ -67,7 +67,7 @@
6767 ATLASSERT(*cache.try_get(3) == 300);
6868 }
6969
70- { // Test empty cache behavior
70+ { // Test empty cache behavior
7171 LruCache<int, int> cache(5);
7272 ATLASSERT(cache.try_get(1) == nullptr);
7373 ATLASSERT(cache.try_get(2) == nullptr);
@@ -74,6 +74,7 @@
7474 ATLASSERT(cache.try_get(3) == nullptr);
7575 }
7676 }
77+ // ReSharper disable once CppInconsistentNaming
7778 } LruCacheTest;
7879
7980 #endif
--- trunk/src/Utils/LruCache.h (revision 29186)
+++ trunk/src/Utils/LruCache.h (revision 29187)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2016 - TortoiseSVN
3+// Copyright (C) 2016, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -22,7 +22,7 @@
2222 #include <unordered_map>
2323 #include <list>
2424
25-template<typename key_t, typename value_t>
25+template <typename KeyT, typename ValueT>
2626 class LruCache
2727 {
2828 public:
@@ -31,14 +31,14 @@
3131 {
3232 }
3333
34- void insert_or_assign(const key_t & key, const value_t & val)
34+ void insert_or_assign(const KeyT& key, const ValueT& val)
3535 {
36- ItemsMap::iterator mapIt = itemsMap.find(key);
36+ auto mapIt = itemsMap.find(key);
3737 if (mapIt == itemsMap.end())
3838 {
3939 evict(maxSize - 1);
4040
41- ItemsList::iterator listIt = itemsList.insert(itemsList.cend(), ListItem(key, val));
41+ auto listIt = itemsList.insert(itemsList.cend(), ListItem(key, val));
4242 itemsMap.insert(std::make_pair(key, listIt));
4343 }
4444 else
@@ -47,9 +47,9 @@
4747 }
4848 }
4949
50- const value_t * try_get(const key_t & key)
50+ const ValueT* try_get(const KeyT& key)
5151 {
52- ItemsMap::const_iterator it = itemsMap.find(key);
52+ auto it = itemsMap.find(key);
5353 if (it == itemsMap.end())
5454 return nullptr;
5555
@@ -72,32 +72,31 @@
7272 itemsMap.clear();
7373 itemsList.clear();
7474 }
75+
7576 protected:
7677 void evict(size_t itemsToKeep)
7778 {
78- for(ItemsList::iterator it = itemsList.begin();
79- itemsList.size() > itemsToKeep && it != itemsList.end();)
79+ for (auto it = itemsList.begin(); itemsList.size() > itemsToKeep && it != itemsList.end();)
8080 {
8181 itemsMap.erase(it->key);
8282 it = itemsList.erase(it);
8383 }
8484 }
85+
8586 private:
8687 struct ListItem
8788 {
88- ListItem(const key_t & key, const value_t & val)
89- : key(key), val(val)
89+ ListItem(const KeyT& key, const ValueT& val)
90+ : key(key)
91+ , val(val)
9092 {
9193 }
9294
93- key_t key;
94- value_t val;
95+ KeyT key;
96+ ValueT val;
9597 };
9698
97- typedef std::list<ListItem> ItemsList;
98- typedef std::unordered_map<key_t, typename ItemsList::iterator> ItemsMap;
99-
100- size_t maxSize;
101- ItemsMap itemsMap;
102- ItemsList itemsList;
99+ size_t maxSize;
100+ std::unordered_map<KeyT, typename std::list<ListItem>::iterator> itemsMap;
101+ std::list<ListItem> itemsList;
103102 };
Show on old repository browser