• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Révision29199 (tree)
l'heure2021-05-05 04:29:28
Auteurstefankueng

Message de Log

use std::make_unique instead of creating it with new

Change Summary

Modification

--- trunk/src/SVN/SVN.cpp (revision 29198)
+++ trunk/src/SVN/SVN.cpp (revision 29199)
@@ -1929,11 +1929,11 @@
19291929 // cached-based queries.
19301930 // Use & update existing cache
19311931
1932- std::unique_ptr<CCacheLogQuery> cacheQuery(new CCacheLogQuery(GetLogCachePool(), &svnQuery));
1932+ auto cacheQuery = std::make_unique<CCacheLogQuery>(GetLogCachePool(), &svnQuery);
19331933
19341934 // run query through SVN but collect results in a temporary cache
19351935
1936- std::unique_ptr<CCacheLogQuery> tempQuery(new CCacheLogQuery(*this, &svnQuery));
1936+ auto tempQuery = std::make_unique<CCacheLogQuery>(*this, &svnQuery);
19371937
19381938 // select query and run it
19391939
--- trunk/src/SVN/SVNConflictInfo.cpp (revision 29198)
+++ trunk/src/SVN/SVNConflictInfo.cpp (revision 29199)
@@ -454,8 +454,7 @@
454454 label = svn_client_conflict_option_get_label(opt, scratchPool);
455455 description = svn_client_conflict_option_get_description(opt, scratchPool);
456456
457- result.push_back(std::unique_ptr<SVNConflictOption>(new SVNConflictOption(opt, id,
458- CUnicodeUtils::GetUnicode(label), CUnicodeUtils::GetUnicode(description), j, -1)));
457+ result.push_back(std::make_unique<SVNConflictOption>(opt, id, CUnicodeUtils::GetUnicode(label), CUnicodeUtils::GetUnicode(description), j, -1));
459458 bResultAdded = true;
460459 }
461460 }
@@ -462,8 +461,7 @@
462461
463462 if (!bResultAdded)
464463 {
465- result.push_back(std::unique_ptr<SVNConflictOption>(new SVNConflictOption(opt, id,
466- CUnicodeUtils::GetUnicode(label), CUnicodeUtils::GetUnicode(description))));
464+ result.push_back(std::make_unique<SVNConflictOption>(opt, id, CUnicodeUtils::GetUnicode(label), CUnicodeUtils::GetUnicode(description)));
467465 }
468466 }
469467
@@ -493,8 +491,7 @@
493491 const char * label = svn_client_conflict_option_get_label(opt, scratchPool);
494492 const char * description = svn_client_conflict_option_get_description(opt, scratchPool);
495493
496- result.push_back(std::unique_ptr<SVNConflictOption>(new SVNConflictOption(opt, id,
497- CUnicodeUtils::GetUnicode(label), CUnicodeUtils::GetUnicode(description))));
494+ result.push_back(std::make_unique<SVNConflictOption>(opt, id, CUnicodeUtils::GetUnicode(label), CUnicodeUtils::GetUnicode(description)));
498495 }
499496
500497 return true;
@@ -523,8 +520,7 @@
523520 const char * label = svn_client_conflict_option_get_label(opt, scratchPool);
524521 const char * description = svn_client_conflict_option_get_description(opt, scratchPool);
525522
526- result.push_back(std::unique_ptr<SVNConflictOption>(new SVNConflictOption(opt, id,
527- CUnicodeUtils::GetUnicode(label), CUnicodeUtils::GetUnicode(description))));
523+ result.push_back(std::make_unique<SVNConflictOption>(opt, id, CUnicodeUtils::GetUnicode(label), CUnicodeUtils::GetUnicode(description)));
528524 }
529525
530526 return true;
--- trunk/src/SVN/SVNConflictInfo.h (revision 29198)
+++ trunk/src/SVN/SVNConflictInfo.h (revision 29199)
@@ -49,7 +49,6 @@
4949 void SetMergedPropVal(const svn_string_t *propVal) const;
5050 svn_error_t *SetMergedPropValFile(const CTSVNPath &filePath, apr_pool_t *pool) const;
5151
52-protected:
5352 SVNConflictOption(svn_client_conflict_option_t * option,
5453 svn_client_conflict_option_id_t id,
5554 const CString & label,
--- trunk/src/SVN/SVNDataObject.cpp (revision 29198)
+++ trunk/src/SVN/SVNDataObject.cpp (revision 29199)
@@ -416,8 +416,8 @@
416416 nLength += 1; // '\0' separator
417417 }
418418
419- int nBufferSize = sizeof(DROPFILES) + (nLength + 1LL) * sizeof(wchar_t);
420- std::unique_ptr<char[]> pBuffer(new char[nBufferSize]);
419+ int nBufferSize = sizeof(DROPFILES) + (nLength + 1LL) * sizeof(wchar_t);
420+ auto pBuffer = std::make_unique<char[]>(nBufferSize);
421421
422422 SecureZeroMemory(pBuffer.get(), nBufferSize);
423423
@@ -452,8 +452,8 @@
452452 }
453453 else if ((pformatetcIn->tymed & TYMED_HGLOBAL) && (pformatetcIn->dwAspect == DVASPECT_CONTENT) && (pformatetcIn->cfFormat == CF_FILE_ATTRIBUTES_ARRAY))
454454 {
455- int nBufferSize = sizeof(FILE_ATTRIBUTES_ARRAY) + m_svnPaths.GetCount() * sizeof(DWORD);
456- std::unique_ptr<char[]> pBuffer(new char[nBufferSize]);
455+ int nBufferSize = sizeof(FILE_ATTRIBUTES_ARRAY) + m_svnPaths.GetCount() * sizeof(DWORD);
456+ auto pBuffer = std::make_unique<char[]>(nBufferSize);
457457
458458 SecureZeroMemory(pBuffer.get(), nBufferSize);
459459
--- trunk/src/SubWCRev/SubWCRevCOM.cpp (revision 29198)
+++ trunk/src/SubWCRev/SubWCRevCOM.cpp (revision 29199)
@@ -316,9 +316,9 @@
316316 if (result == nullptr)
317317 return E_POINTER;
318318
319- result->vt = VT_BSTR;
320- const size_t len = strlen(string);
321- std::unique_ptr<WCHAR[]> buf(new WCHAR[len * 4 + 1]);
319+ result->vt = VT_BSTR;
320+ const size_t len = strlen(string);
321+ auto buf = std::make_unique<wchar_t[]>(len * 4 + 1);
322322 SecureZeroMemory(buf.get(), (len * 4 + 1) * sizeof(WCHAR));
323323 MultiByteToWideChar(CP_UTF8, 0, string, -1, buf.get(), static_cast<int>(len) * 4);
324324 result->bstrVal = SysAllocString(buf.get());
@@ -431,7 +431,7 @@
431431 result = S_OK;
432432 }
433433
434- std::unique_ptr<WCHAR[]> buf(new WCHAR[len * 4 + 1]);
434+ auto buf = std::make_unique<wchar_t[]>(len * 4 + 1);
435435 SecureZeroMemory(buf.get(), (len * 4 + 1) * sizeof(WCHAR));
436436
437437 if (TRUE == m_subStat.lockData.needsLocks)
@@ -464,7 +464,7 @@
464464 result = S_OK;
465465 }
466466
467- std::unique_ptr<WCHAR[]> buf(new WCHAR[len * 4 + 1]);
467+ auto buf = std::make_unique<wchar_t[]>(len * 4 + 1);
468468 SecureZeroMemory(buf.get(), (len * 4 + 1) * sizeof(WCHAR));
469469
470470 if (TRUE == m_subStat.lockData.needsLocks)
--- trunk/src/SubWCRev/UnicodeUtils.cpp (revision 29198)
+++ trunk/src/SubWCRev/UnicodeUtils.cpp (revision 29199)
@@ -1,4 +1,4 @@
1-// Copyright (C) 2007, 2010-2012 - TortoiseSVN
1+// Copyright (C) 2007, 2010-2012, 2021 - TortoiseSVN
22
33 // this program is free software; you can redistribute it and/or
44 // modify it under the terms of the GNU General Public License
@@ -17,35 +17,35 @@
1717 #include "UnicodeUtils.h"
1818 #include <memory>
1919
20-char * AnsiToUtf8(const char * pszAnsi, apr_pool_t *pool)
20+char *AnsiToUtf8(const char *pszAnsi, apr_pool_t *pool)
2121 {
2222 // convert ANSI --> UTF16
23- int utf16_count = MultiByteToWideChar(CP_ACP, 0, pszAnsi, -1, NULL, 0);
24- std::unique_ptr<WCHAR[]> pwc(new WCHAR[utf16_count]);
25- MultiByteToWideChar(CP_ACP, 0, pszAnsi, -1, pwc.get(), utf16_count);
23+ int utf16Count = MultiByteToWideChar(CP_ACP, 0, pszAnsi, -1, nullptr, 0);
24+ auto pwc = std::make_unique<wchar_t[]>(utf16Count);
25+ MultiByteToWideChar(CP_ACP, 0, pszAnsi, -1, pwc.get(), utf16Count);
2626
2727 // and now from URF16 --> UTF-8
28- int utf8_count = WideCharToMultiByte(CP_UTF8, 0, pwc.get(), utf16_count, NULL, 0, NULL, NULL);
29- char * pch = (char*) apr_palloc(pool, utf8_count);
30- WideCharToMultiByte(CP_UTF8, 0, pwc.get(), utf16_count, pch, utf8_count, NULL, NULL);
28+ int utf8Count = WideCharToMultiByte(CP_UTF8, 0, pwc.get(), utf16Count, nullptr, 0, nullptr, nullptr);
29+ char *pch = static_cast<char *>(apr_palloc(pool, utf8Count));
30+ WideCharToMultiByte(CP_UTF8, 0, pwc.get(), utf16Count, pch, utf8Count, nullptr, nullptr);
3131 return pch;
3232 }
3333
34-char * Utf16ToUtf8(const WCHAR *pszUtf16, apr_pool_t *pool)
34+char *Utf16ToUtf8(const wchar_t *pszUtf16, apr_pool_t *pool)
3535 {
3636 // from URF16 --> UTF-8
37- int utf8_count = WideCharToMultiByte(CP_UTF8, 0, pszUtf16, -1, NULL, 0, NULL, NULL);
38- char * pch = (char*) apr_palloc(pool, utf8_count);
39- WideCharToMultiByte(CP_UTF8, 0, pszUtf16, -1, pch, utf8_count, NULL, NULL);
37+ int utf8Count = WideCharToMultiByte(CP_UTF8, 0, pszUtf16, -1, nullptr, 0, nullptr, nullptr);
38+ char *pch = static_cast<char *>(apr_palloc(pool, utf8Count));
39+ WideCharToMultiByte(CP_UTF8, 0, pszUtf16, -1, pch, utf8Count, nullptr, nullptr);
4040 return pch;
4141 }
4242
43-std::wstring Utf8ToWide(const std::string& string)
43+std::wstring Utf8ToWide(const std::string &string)
4444 {
4545 const size_t len = string.size();
46- std::unique_ptr<WCHAR[]> buf(new WCHAR[len*4 + 1]);
47- SecureZeroMemory(buf.get(), (len*4 + 1)*sizeof(WCHAR));
48- MultiByteToWideChar(CP_UTF8, 0, string.c_str(), -1, buf.get(), (int)len*4);
46+ auto buf = std::make_unique<wchar_t[]>(len * 4 + 1);
47+ SecureZeroMemory(buf.get(), (len * 4 + 1) * sizeof(wchar_t));
48+ MultiByteToWideChar(CP_UTF8, 0, string.c_str(), -1, buf.get(), static_cast<int>(len) * 4);
4949 std::wstring ret = std::wstring(buf.get());
5050 return ret;
5151 }
--- trunk/src/SubWCRev/UnicodeUtils.h (revision 29198)
+++ trunk/src/SubWCRev/UnicodeUtils.h (revision 29199)
@@ -1,4 +1,4 @@
1-// Copyright (C) 2007, 2011-2013 - TortoiseSVN
1+// Copyright (C) 2007, 2011-2013, 2021 - TortoiseSVN
22
33 // This program is free software; you can redistribute it and/or
44 // modify it under the terms of the GNU General Public License
@@ -20,17 +20,16 @@
2020 * \ingroup SubWCRev
2121 * Converts an ANSI string to UTF8.
2222 */
23-char * AnsiToUtf8(const char * pszAnsi, apr_pool_t *pool);
23+char *AnsiToUtf8(const char *pszAnsi, apr_pool_t *pool);
2424
2525 /**
2626 * \ingroup SubWCRev
2727 * Converts an UTF16 string to UTF8
2828 */
29-char * Utf16ToUtf8(const WCHAR *pszUtf16, apr_pool_t *pool);
29+char *Utf16ToUtf8(const wchar_t *pszUtf16, apr_pool_t *pool);
3030
3131 /**
3232 * \ingroup SubWCRev
3333 * Converts an UTF8 string to UTF16
3434 */
35-std::wstring Utf8ToWide(const std::string& string);
36-
35+std::wstring Utf8ToWide(const std::string &string);
--- trunk/src/TortoiseProc/Commands/RevisionGraphCommand.cpp (revision 29198)
+++ trunk/src/TortoiseProc/Commands/RevisionGraphCommand.cpp (revision 29199)
@@ -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, 2009-2011, 2013-2014 - TortoiseSVN
3+// Copyright (C) 2007, 2009-2011, 2013-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
@@ -23,12 +23,12 @@
2323
2424 bool RevisionGraphCommand::Execute()
2525 {
26- CString val = parser.GetVal(L"pegrev");
27- SVNRev pegrev = val.IsEmpty() ? SVNRev() : SVNRev(val);
26+ CString val = parser.GetVal(L"pegrev");
27+ SVNRev pegRev = val.IsEmpty() ? SVNRev() : SVNRev(val);
2828
29- std::unique_ptr<CRevisionGraphDlg> dlg(new CRevisionGraphDlg());
29+ auto dlg = std::make_unique<CRevisionGraphDlg>();
3030 dlg->SetPath(cmdLinePath.GetUIPathString());
31- dlg->SetPegRevision(pegrev);
31+ dlg->SetPegRevision(pegRev);
3232 if (parser.HasVal(L"output"))
3333 {
3434 dlg->SetOutputFile(parser.GetVal(L"output"));
--- trunk/src/TortoiseProc/LogDialog/LogDlg.cpp (revision 29198)
+++ trunk/src/TortoiseProc/LogDialog/LogDlg.cpp (revision 29199)
@@ -9312,8 +9312,8 @@
93129312 sRootRobotsURL += _T("/svnrobots.txt");
93139313 CTSVNPath sFile = CTempFiles::Instance().GetTempFilePath(true);
93149314 OnOutOfScope(DeleteFile(sFile.GetWinPath()));
9315- std::string in;
9316- std::unique_ptr<CCallback> callback(new CCallback);
9315+ std::string in;
9316+ auto callback = std::make_unique<CCallback>();
93179317 if (callback == nullptr)
93189318 continue;
93199319 {
--- trunk/src/TortoiseProc/Properties/EditPropertiesDlg.cpp (revision 29198)
+++ trunk/src/TortoiseProc/Properties/EditPropertiesDlg.cpp (revision 29199)
@@ -1191,7 +1191,7 @@
11911191 bFailed = true;
11921192 continue;
11931193 }
1194- std::unique_ptr<wchar_t[]> pNameBuf(new wchar_t[nNameBytes / sizeof(wchar_t)]);
1194+ auto pNameBuf = std::make_unique<wchar_t[]>(nNameBytes / sizeof(wchar_t));
11951195 if (fread(pNameBuf.get(), 1, nNameBytes, stream) == static_cast<size_t>(nNameBytes))
11961196 {
11971197 std::string sName = CUnicodeUtils::StdGetUTF8(std::wstring(pNameBuf.get(), nNameBytes / sizeof(wchar_t)));
@@ -1199,7 +1199,7 @@
11991199 int nValueBytes = 0;
12001200 if (fread(&nValueBytes, sizeof(int), 1, stream) == 1)
12011201 {
1202- std::unique_ptr<BYTE[]> pValueBuf(new BYTE[nValueBytes]);
1202+ auto pValueBuf = std::make_unique<BYTE[]>(nValueBytes);
12031203 if (fread(pValueBuf.get(), sizeof(char), nValueBytes, stream) == static_cast<size_t>(nValueBytes))
12041204 {
12051205 std::string propertyvalue;
--- trunk/src/TortoiseProc/Properties/EditPropertyValueDlg.cpp (revision 29198)
+++ trunk/src/TortoiseProc/Properties/EditPropertyValueDlg.cpp (revision 29199)
@@ -420,7 +420,7 @@
420420 DWORD size = GetFileSize(hFile, nullptr);
421421 FILE* stream = nullptr;
422422 _tfopen_s(&stream, openPath, L"rbS");
423- std::unique_ptr<char[]> buf(new char[size]);
423+ auto buf = std::make_unique<char[]>(size);
424424 if (fread(buf.get(), sizeof(char), size, stream) == size)
425425 {
426426 m_propValue.assign(buf.get(), size);
--- trunk/src/TortoiseProc/RepositoryBrowser.cpp (revision 29198)
+++ trunk/src/TortoiseProc/RepositoryBrowser.cpp (revision 29199)
@@ -28,7 +28,6 @@
2828 #include "RepositoryBrowser.h"
2929 #include "BrowseFolder.h"
3030 #include "RenameDlg.h"
31-#include "RevisionGraph/RevisionGraphDlg.h"
3231 #include "ExportDlg.h"
3332 #include "SVNProgressDlg.h"
3433 #include "AppUtils.h"
@@ -2028,6 +2027,7 @@
20282027 m_barRepository.OnGoUp();
20292028 }
20302029
2030+// ReSharper disable once CppMemberFunctionMayBeConst
20312031 void CRepositoryBrowser::OnUrlFocus()
20322032 {
20332033 m_barRepository.SetFocusToURL();
@@ -2686,7 +2686,7 @@
26862686 void CRepositoryBrowser::OnCbenDragbeginUrlcombo(NMHDR* /*pNMHDR*/, LRESULT* pResult)
26872687 {
26882688 // build copy source / content
2689- std::unique_ptr<CIDropSource> pdSrc(new CIDropSource);
2689+ auto pdSrc = std::make_unique<CIDropSource>();
26902690 if (pdSrc == nullptr)
26912691 return;
26922692
@@ -3771,7 +3771,7 @@
37713771 case ID_EXPORT:
37723772 {
37733773 CExportDlg dlg(this);
3774- dlg.m_url = selection.GetURL(0, 0).GetSVNPathString();
3774+ dlg.m_url = selection.GetURL(0, 0).GetSVNPathString();
37753775 dlg.m_revision = selection.GetRepository(0).revision;
37763776 if (dlg.DoModal() == IDOK)
37773777 {
@@ -5043,7 +5043,7 @@
50435043 CTSVNPath tempfile = CTempFiles::Instance().GetTempFilePath(true);
50445044 // custom callback object required to bypass invalid SSL certificates
50455045 // and handle possible authentication dialogs
5046- std::unique_ptr<CCallback> callback(new CCallback());
5046+ auto callback = std::make_unique<CCallback>();
50475047 callback->SetAuthParentWindow(GetSafeHwnd());
50485048
50495049 // since html pages returned by SVNParentPath contain the listed repository
@@ -5062,7 +5062,7 @@
50625062 // set up the SVNParentPath url as the repo root, even though it isn't a real repo root
50635063 m_repository.root = m_initialUrl;
50645064 m_repository.revision = SVNRev::REV_HEAD;
5065- m_repository.pegRevision = SVNRev::REV_HEAD;
5065+ m_repository.pegRevision = SVNRev::REV_HEAD;
50665066 m_repository.isSVNParentPath = true;
50675067
50685068 // insert our pseudo repo root into the tree view.
@@ -5144,10 +5144,10 @@
51445144 item.m_kind = svn_node_dir;
51455145 item.m_path = sMatch;
51465146 SRepositoryInfo repoInfo;
5147- repoInfo.root = url;
5148- repoInfo.revision = SVNRev::REV_HEAD;
5147+ repoInfo.root = url;
5148+ repoInfo.revision = SVNRev::REV_HEAD;
51495149 repoInfo.pegRevision = SVNRev::REV_HEAD;
5150- item.m_repository = repoInfo;
5150+ item.m_repository = repoInfo;
51515151 AutoInsert(hRoot, item);
51525152 ++nCountNewEntries;
51535153 }
@@ -5170,10 +5170,10 @@
51705170 item.m_kind = svn_node_dir;
51715171 item.m_path = sMatch;
51725172 SRepositoryInfo repoInfo;
5173- repoInfo.root = url;
5174- repoInfo.revision = SVNRev::REV_HEAD;
5173+ repoInfo.root = url;
5174+ repoInfo.revision = SVNRev::REV_HEAD;
51755175 repoInfo.pegRevision = SVNRev::REV_HEAD;
5176- item.m_repository = repoInfo;
5176+ item.m_repository = repoInfo;
51775177 AutoInsert(hRoot, item);
51785178 ++nCountNewEntries;
51795179 }
--- trunk/src/TortoiseProc/RevisionGraph/FullGraphBuilder.cpp (revision 29198)
+++ trunk/src/TortoiseProc/RevisionGraph/FullGraphBuilder.cpp (revision 29199)
@@ -58,7 +58,7 @@
5858
5959 // initialize the paths we have to search for
6060
61- std::unique_ptr<CSearchPathTree> searchTree(new CSearchPathTree(&revisionInfo.GetPaths()));
61+ auto searchTree = std::make_unique<CSearchPathTree>(&revisionInfo.GetPaths());
6262 searchTree->Insert(*m_history.GetStartPath(), m_history.GetStartRevision());
6363
6464 // the range of copy-to info that applies to the current revision
--- trunk/src/TortoiseProc/RevisionGraph/RevisionGraphDlgFunc.cpp (revision 29198)
+++ trunk/src/TortoiseProc/RevisionGraph/RevisionGraphDlgFunc.cpp (revision 29199)
@@ -203,7 +203,7 @@
203203 return false;
204204 }
205205
206- std::unique_ptr<CFullHistory> newFullHistory(new CFullHistory());
206+ auto newFullHistory = std::make_unique<CFullHistory>();
207207
208208 bool showWCRev = m_state.GetOptions()->GetOption<CShowWC>()->IsSelected();
209209 bool showWCModification = m_state.GetOptions()->GetOption<CShowWCModification>()->IsSelected();
@@ -219,7 +219,7 @@
219219
220220 if (result)
221221 {
222- std::unique_ptr<CFullGraph> newFullGraph(new CFullGraph());
222+ auto newFullGraph = std::make_unique<CFullGraph>();
223223
224224 CFullGraphBuilder builder(*newFullHistory, *newFullGraph);
225225 builder.Run();
@@ -254,7 +254,7 @@
254254
255255 // layout nodes
256256
257- std::unique_ptr<CStandardLayout> newLayout(new CStandardLayout(m_state.GetFullHistory()->GetCache(), visibleGraph.get(), m_state.GetFullHistory()->GetWCInfo()));
257+ auto newLayout = std::make_unique<CStandardLayout>(m_state.GetFullHistory()->GetCache(), visibleGraph.get(), m_state.GetFullHistory()->GetWCInfo());
258258 options->GetLayoutOptions().Apply(newLayout.get(), GetSafeHwnd());
259259 newLayout->Finalize();
260260
--- trunk/src/TortoiseProc/SVNProgressDlg.cpp (revision 29198)
+++ trunk/src/TortoiseProc/SVNProgressDlg.cpp (revision 29199)
@@ -2505,10 +2505,10 @@
25052505 return;
25062506 }
25072507
2508- std::unique_ptr<CIDropSource> pdsrc(new CIDropSource);
2509- if (pdsrc == nullptr)
2508+ auto pdSrc = std::make_unique<CIDropSource>();
2509+ if (pdSrc == nullptr)
25102510 return;
2511- pdsrc->AddRef();
2511+ pdSrc->AddRef();
25122512
25132513 SVNDataObject* pdobj = new SVNDataObject(pathList, SVNRev::REV_WC, SVNRev::REV_WC);
25142514 if (pdobj == nullptr)
@@ -2521,14 +2521,14 @@
25212521
25222522 dragsrchelper.InitializeFromWindow(m_progList.GetSafeHwnd(), pNMLV->ptAction, pdobj);
25232523
2524- pdsrc->m_pIDataObj = pdobj;
2525- pdsrc->m_pIDataObj->AddRef();
2524+ pdSrc->m_pIDataObj = pdobj;
2525+ pdSrc->m_pIDataObj->AddRef();
25262526
25272527 // Initiate the Drag & Drop
25282528 DWORD dwEffect;
2529- ::DoDragDrop(pdobj, pdsrc.get(), DROPEFFECT_MOVE | DROPEFFECT_COPY, &dwEffect);
2530- pdsrc->Release();
2531- pdsrc.release();
2529+ ::DoDragDrop(pdobj, pdSrc.get(), DROPEFFECT_MOVE | DROPEFFECT_COPY, &dwEffect);
2530+ pdSrc->Release();
2531+ pdSrc.release();
25322532 pdobj->Release();
25332533 }
25342534
--- trunk/src/TortoiseShell/SVNPropertyPage.cpp (revision 29198)
+++ trunk/src/TortoiseShell/SVNPropertyPage.cpp (revision 29199)
@@ -295,12 +295,12 @@
295295 {
296296 size_t len = strlen(svn.status->repos_relpath) + strlen(svn.status->repos_root_url);
297297 len += 2;
298- std::unique_ptr<char[]> url(new char[len * 4]);
298+ auto url = std::make_unique<char[]>(len * 4);
299299 strcpy_s(url.get(), len * 4, svn.status->repos_root_url);
300300 strcat_s(url.get(), len * 4, "/");
301301 strcat_s(url.get(), len * 4, svn.status->repos_relpath);
302302
303- std::unique_ptr<char[]> unescapedurl(new char[len]);
303+ auto unescapedurl = std::make_unique<char[]>(len);
304304 strcpy_s(unescapedurl.get(), len, url.get());
305305 CStringA escapedurl = CPathUtils::PathEscape(url.get());
306306 CPathUtils::Unescape(unescapedurl.get());
--- trunk/src/TortoiseShell/ShellExt.cpp (revision 29198)
+++ trunk/src/TortoiseShell/ShellExt.cpp (revision 29199)
@@ -115,7 +115,7 @@
115115
116116 if (dwBufferSize > 0)
117117 {
118- std::unique_ptr<char[]> buffer(new char[dwBufferSize]);
118+ auto buffer = std::make_unique<char[]>(dwBufferSize);
119119
120120 if (buffer.get() != nullptr)
121121 {
@@ -202,9 +202,9 @@
202202 do
203203 {
204204 bufferLen += MAX_PATH; // MAX_PATH is not the limit here!
205- std::unique_ptr<wchar_t[]> pBuf(new wchar_t[bufferLen]);
206- len = GetModuleFileName(g_hModThisDll, pBuf.get(), bufferLen);
207- path = std::wstring(pBuf.get(), len);
205+ auto pBuf = std::make_unique<wchar_t[]>(bufferLen);
206+ len = GetModuleFileName(g_hModThisDll, pBuf.get(), bufferLen);
207+ path = std::wstring(pBuf.get(), len);
208208 } while (len == bufferLen);
209209 path = path.substr(0, path.rfind('\\') + 1);
210210
--- trunk/src/Utils/MiscUI/HighColorTab.hpp (revision 29198)
+++ trunk/src/Utils/MiscUI/HighColorTab.hpp (revision 29199)
@@ -11,18 +11,13 @@
1111 //
1212 ///////////////////////////////////////////////////////////////////////////////
1313
14-#ifndef _HIGHCOLORTAB_HPP_INCLUDED_
15-#define _HIGHCOLORTAB_HPP_INCLUDED_
16-
17-#if _MSC_VER > 1000
1814 #pragma once
19-#endif // _MSC_VER > 1000
2015
2116 #include <memory>
2217
2318 namespace HighColorTab
2419 {
25- /*! \brief Policy class for creating image list.
20+/*! \brief Policy class for creating image list.
2621
2722 Policy for creating a high color (32 bits) image list. The policy
2823 ensure that there is a Win32 image list associated with the CImageList.
@@ -31,35 +26,33 @@
3126 Returned image list is wrapped in an std::unique_ptr.
3227
3328 \sa UpdateImageListFull */
34- struct CHighColorListCreator
35- {
29+struct CHighColorListCreator
30+{
3631 /*! Create the image list.
3732 \retval std::unique_ptr<CImageList> Not null if success. */
3833 static std::unique_ptr<CImageList> CreateImageList(int w, int h)
3934 {
40- std::unique_ptr<CImageList> apILNew( new CImageList() );
41- if( NULL == apILNew.get() )
42- {
43- // ASSERT: The CImageList object creation failed.
44- ASSERT( FALSE );
45- return std::unique_ptr<CImageList>();
46- }
35+ auto apIlNew = std::make_unique<CImageList>();
36+ if (nullptr == apIlNew.get())
37+ {
38+ // ASSERT: The CImageList object creation failed.
39+ ASSERT(FALSE);
40+ return std::unique_ptr<CImageList>();
41+ }
4742
48- if (0 == apILNew->Create(w, h, ILC_COLOR32 | ILC_MASK | ILC_HIGHQUALITYSCALE, 0, 1))
49- {
50- // ASSERT: The image list (Win32) creation failed.
51- ASSERT( FALSE );
52- return std::unique_ptr<CImageList>();
53- }
43+ if (0 == apIlNew->Create(w, h, ILC_COLOR32 | ILC_MASK | ILC_HIGHQUALITYSCALE, 0, 1))
44+ {
45+ // ASSERT: The image list (Win32) creation failed.
46+ ASSERT(FALSE);
47+ return std::unique_ptr<CImageList>();
48+ }
5449
55- return apILNew;
50+ return apIlNew;
5651 }
57- };
52+};
5853
54+/*! \brief Change the image list of the provided control (property sheet interface)
5955
60-
61- /*! \brief Change the image list of the provided control (property sheet interface)
62-
6356 This method provides full customization via policy over image list creation. The policy
6457 must have a method with the signature:
6558 <code>static std::unique_ptr<CImageList> CreateImageList()</code>
@@ -66,75 +59,73 @@
6659
6760 \author Yves Tkaczyk (yves@tkaczyk.net)
6861 \date 02/2004 */
69- template<typename TSheet,
70- typename TListCreator>
71- bool UpdateImageListFull(TSheet& rSheet, int w, int h)
72- {
73- // Get the tab control...
74- CTabCtrl* pTab = rSheet.GetTabControl();
75- if (!IsWindow(pTab->GetSafeHwnd()))
76- {
77- // ASSERT: Tab control could not be retrieved or it is not a valid window.
78- ASSERT( FALSE );
79- return false;
80- }
62+template <typename TSheet,
63+ typename TListCreator>
64+bool UpdateImageListFull(TSheet& rSheet, int w, int h)
65+{
66+ // Get the tab control...
67+ CTabCtrl* pTab = rSheet.GetTabControl();
68+ if (!IsWindow(pTab->GetSafeHwnd()))
69+ {
70+ // ASSERT: Tab control could not be retrieved or it is not a valid window.
71+ ASSERT(FALSE);
72+ return false;
73+ }
8174
8275 // Create the replacement image list via policy.
83- std::unique_ptr<CImageList> apILNew(TListCreator::CreateImageList(w, h));
76+ std::unique_ptr<CImageList> apIlNew(TListCreator::CreateImageList(w, h));
8477
85- bool bSuccess = (NULL != apILNew.get() );
78+ bool bSuccess = (nullptr != apIlNew.get());
8679
8780 // Reload the icons from the property pages.
8881 int nTotalPageCount = rSheet.GetPageCount();
89- for(int nCurrentPage = 0; nCurrentPage < nTotalPageCount && bSuccess; ++nCurrentPage )
82+ for (int nCurrentPage = 0; nCurrentPage < nTotalPageCount && bSuccess; ++nCurrentPage)
9083 {
91- // Get the page.
92- CPropertyPage* pPage = rSheet.GetPage( nCurrentPage );
93- ASSERT( pPage );
94- // Set the icon in the image list from the page properties.
95- if( pPage && ( pPage->m_psp.dwFlags & PSP_USEHICON ) )
96- {
97- bSuccess &= ( -1 != apILNew->Add( pPage->m_psp.hIcon ) );
98- }
84+ // Get the page.
85+ CPropertyPage* pPage = rSheet.GetPage(nCurrentPage);
86+ ASSERT(pPage);
87+ // Set the icon in the image list from the page properties.
88+ if (pPage && (pPage->m_psp.dwFlags & PSP_USEHICON))
89+ {
90+ bSuccess &= (-1 != apIlNew->Add(pPage->m_psp.hIcon));
91+ }
9992
100- if( pPage && ( pPage->m_psp.dwFlags & PSP_USEICONID ) )
101- {
102- bSuccess &= ( -1 != apILNew->Add( AfxGetApp()->LoadIcon( pPage->m_psp.pszIcon ) ) );
103- }
93+ if (pPage && (pPage->m_psp.dwFlags & PSP_USEICONID))
94+ {
95+ bSuccess &= (-1 != apIlNew->Add(AfxGetApp()->LoadIcon(pPage->m_psp.pszIcon)));
96+ }
10497 }
10598
106- if( !bSuccess )
99+ if (!bSuccess)
107100 {
108- // This ASSERT because either the image list could not be created or icon insertion failed.
109- ASSERT( FALSE );
110- // Cleanup what we have in the new image list.
111- if( apILNew.get() )
112- {
113- apILNew->DeleteImageList();
114- }
101+ // This ASSERT because either the image list could not be created or icon insertion failed.
102+ ASSERT(FALSE);
103+ // Cleanup what we have in the new image list.
104+ if (apIlNew.get())
105+ {
106+ apIlNew->DeleteImageList();
107+ }
115108
116- return false;
109+ return false;
117110 }
118111
119112 // Replace the image list from the tab control.
120- CImageList* pilOld = pTab->SetImageList( CImageList::FromHandle( apILNew->Detach() ) );
113+ CImageList* pilOld = pTab->SetImageList(CImageList::FromHandle(apIlNew->Detach()));
121114 // Clean the old image list if there was one.
122- if( pilOld )
115+ if (pilOld)
123116 {
124- pilOld->DeleteImageList();
117+ pilOld->DeleteImageList();
125118 }
126119
127120 return true;
128- };
121+};
129122
130- /*! \brief Change the image list of the provided control (property sheet)
123+/*! \brief Change the image list of the provided control (property sheet)
131124
132125 This method uses 32 bits image list creation default policy. */
133- template<typename TSheet>
134- bool UpdateImageList(TSheet& rSheet, int w, int h)
135- {
126+template <typename TSheet>
127+bool UpdateImageList(TSheet& rSheet, int w, int h)
128+{
136129 return UpdateImageListFull<TSheet, HighColorTab::CHighColorListCreator>(rSheet, w, h);
137- };
138130 };
139-
140-#endif // _HIGHCOLORTAB_HPP_INCLUDED_
131+}; // namespace HighColorTab
--- trunk/src/Utils/PathWatcher.cpp (revision 29198)
+++ trunk/src/Utils/PathWatcher.cpp (revision 29199)
@@ -234,8 +234,8 @@
234234 break;
235235 }
236236
237- std::unique_ptr<CDirWatchInfo> pDirInfo(new CDirWatchInfo(std::move(hDir), watchedPaths[i])); // the new CDirWatchInfo object owns the handle now
238- m_hCompPort = CreateIoCompletionPort(pDirInfo->m_hDir, m_hCompPort, reinterpret_cast<ULONG_PTR>(pDirInfo.get()), 0);
237+ auto pDirInfo = std::make_unique<CDirWatchInfo>(std::move(hDir), watchedPaths[i]); // the new CDirWatchInfo object owns the handle now
238+ m_hCompPort = CreateIoCompletionPort(pDirInfo->m_hDir, m_hCompPort, reinterpret_cast<ULONG_PTR>(pDirInfo.get()), 0);
239239 if (m_hCompPort == NULL)
240240 {
241241 AutoLocker lock(m_critSec);
--- trunk/src/Utils/StringUtils.cpp (revision 29198)
+++ trunk/src/Utils/StringUtils.cpp (revision 29199)
@@ -764,10 +764,10 @@
764764 // Create block cipher session key based on hash of the password.
765765 if (CryptDeriveKey(hProv, CALG_AES_256, hHash, CRYPT_EXPORTABLE, &hKey))
766766 {
767- dwLength = static_cast<DWORD>(s.size() + 1024); // 1024 bytes should be enough for padding
768- std::unique_ptr<BYTE[]> buffer(new BYTE[dwLength]);
767+ dwLength = static_cast<DWORD>(s.size() + 1024); // 1024 bytes should be enough for padding
768+ auto buffer = std::make_unique<BYTE[]>(dwLength);
769769
770- std::unique_ptr<BYTE[]> strIn(new BYTE[s.size() + 1]);
770+ auto strIn = std::make_unique<BYTE[]>(s.size() + 1);
771771 if (buffer && strIn)
772772 {
773773 if (CStringUtils::FromHexString(s, strIn.get()))
--- trunk/src/Utils/Theme.cpp (revision 29198)
+++ trunk/src/Utils/Theme.cpp (revision 29199)
@@ -687,12 +687,12 @@
687687 GetEditBorderColor(hWnd, &cr);
688688 cr |= 0xff000000;
689689
690- std::unique_ptr<Gdiplus::Pen> myPen(new Gdiplus::Pen(Gdiplus::Color(cr), 1));
691- std::unique_ptr<Gdiplus::Graphics> myGraphics(new Gdiplus::Graphics(hdcPaint));
692- int iY = RECTHEIGHT(rcDraw) / 2;
693- Gdiplus::Rect rr = Gdiplus::Rect(rcClient.left, rcClient.top + iY,
690+ auto myPen = std::make_unique<Gdiplus::Pen>(Gdiplus::Color(cr));
691+ auto myGraphics = std::make_unique<Gdiplus::Graphics>(hdcPaint);
692+ int iY = RECTHEIGHT(rcDraw) / 2;
693+ Gdiplus::Rect rr = Gdiplus::Rect(rcClient.left, rcClient.top + iY,
694694 RECTWIDTH(rcClient), RECTHEIGHT(rcClient) - iY - 1);
695- Gdiplus::GraphicsPath path;
695+ Gdiplus::GraphicsPath path;
696696 GetRoundRectPath(&path, rr, 5);
697697 myGraphics->DrawPath(myPen.get(), &path);
698698 myGraphics.reset();
@@ -1287,9 +1287,9 @@
12871287
12881288 void DrawRect(LPRECT prc, HDC hdcPaint, Gdiplus::DashStyle dashStyle, Gdiplus::Color clr, Gdiplus::REAL width)
12891289 {
1290- std::unique_ptr<Gdiplus::Pen> myPen(new Gdiplus::Pen(clr, width));
1290+ auto myPen = std::make_unique<Gdiplus::Pen>(clr, width);
12911291 myPen->SetDashStyle(dashStyle);
1292- std::unique_ptr<Gdiplus::Graphics> myGraphics(new Gdiplus::Graphics(hdcPaint));
1292+ auto myGraphics = std::make_unique<Gdiplus::Graphics>(hdcPaint);
12931293
12941294 myGraphics->DrawRectangle(myPen.get(), prc->left, prc->top,
12951295 prc->right - 1 - prc->left, prc->bottom - 1 - prc->top);
Afficher sur ancien navigateur de dépôt.