• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Révision29479 (tree)
l'heure2022-11-19 00:16:19
Auteurstefankueng

Message de Log

implement the CExplorerCommand as a WinRT Runtime component to work around an issue with the explorer context menu

Change Summary

Modification

--- trunk/src/Changelog.txt (revision 29478)
+++ trunk/src/Changelog.txt (revision 29479)
@@ -4,6 +4,8 @@
44 used the wrong path. (Stefan)
55 - BUG: the revision graph did not show the HEAD revision
66 if not all revisions were shown. (Stefan)
7+- BUG: context menu items in Win11 did show up but
8+ didn't invoke the command. (Stefan
79
810 Version 1.14.5
911 - BUG: 1.14.4 was wrongly linked against svn 1.14.1
--- trunk/src/TortoiseShell/ContextMenu.cpp (revision 29478)
+++ trunk/src/TortoiseShell/ContextMenu.cpp (revision 29479)
@@ -807,7 +807,7 @@
807807 if (menu)
808808 InsertMenuItem(menu, pos, TRUE, &menuItemInfo);
809809 else
810- m_explorerCommands.push_back(CExplorerCommand(menuTextBuffer, icon, com, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
810+ m_explorerCommands.push_back(Microsoft::WRL::Make<CExplorerCommand>(menuTextBuffer, icon, com, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
811811
812812 myVerbsMap[verb] = id - idCmdFirst;
813813 myVerbsMap[verb] = id;
@@ -1173,7 +1173,7 @@
11731173 if (subMenu)
11741174 InsertMenu(subMenu, indexSubMenu++, MF_SEPARATOR | MF_BYPOSITION, 0, nullptr);
11751175 else
1176- m_explorerCommands.push_back(CExplorerCommand(L"", 0, 0, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
1176+ m_explorerCommands.push_back(Microsoft::WRL::Make<CExplorerCommand>(L"", 0, 0, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
11771177 idCmd++;
11781178 }
11791179
@@ -1802,7 +1802,7 @@
18021802 break;
18031803 default:
18041804 break;
1805- //#endregion
1805+ // #endregion
18061806 } // switch (id_it->second)
18071807 if (!svnCmd.empty())
18081808 {
@@ -2123,12 +2123,12 @@
21232123 unsigned __int64 topMenu,
21242124 bool bShowIcons)
21252125 {
2126- HMENU ignoreSubMenu = nullptr;
2127- int indexIgnoreSub = 0;
2128- bool bShowIgnoreMenu = false;
2129- wchar_t maskBuf[MAX_PATH] = {0}; // MAX_PATH is ok, since this only holds a filename
2130- wchar_t ignorePath[MAX_PATH] = {0}; // MAX_PATH is ok, since this only holds a filename
2131- std::vector<CExplorerCommand> exCmds;
2126+ HMENU ignoreSubMenu = nullptr;
2127+ int indexIgnoreSub = 0;
2128+ bool bShowIgnoreMenu = false;
2129+ wchar_t maskBuf[MAX_PATH] = {0}; // MAX_PATH is ok, since this only holds a filename
2130+ wchar_t ignorePath[MAX_PATH] = {0}; // MAX_PATH is ok, since this only holds a filename
2131+ std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>> exCmds;
21322132
21332133 if (m_files.empty())
21342134 return;
@@ -2163,7 +2163,7 @@
21632163 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, ignorePath);
21642164 }
21652165 else
2166- exCmds.push_back(CExplorerCommand(ignorePath, 0, ShellMenuUnIgnore, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2166+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(ignorePath, 0, ShellMenuUnIgnore, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
21672167 std::wstring verb = L"tsvn_" + std::wstring(ignorePath);
21682168 myVerbsMap[verb] = idCmd - idCmdFirst;
21692169 myVerbsMap[verb] = idCmd;
@@ -2194,7 +2194,7 @@
21942194 if (hMenu)
21952195 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp);
21962196 else
2197- exCmds.push_back(CExplorerCommand(static_cast<LPCWSTR>(temp), 0, ShellMenuUnIgnoreGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2197+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(static_cast<LPCWSTR>(temp), 0, ShellMenuUnIgnoreGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
21982198 std::wstring verb = L"tsvn_" + std::wstring(temp);
21992199 myVerbsMap[verb] = idCmd - idCmdFirst;
22002200 myVerbsMap[verb] = idCmd;
@@ -2219,7 +2219,7 @@
22192219 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, maskBuf);
22202220 }
22212221 else
2222- exCmds.push_back(CExplorerCommand(maskBuf, 0, ShellMenuUnIgnoreCaseSensitive, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2222+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(maskBuf, 0, ShellMenuUnIgnoreCaseSensitive, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
22232223 std::wstring verb = L"tsvn_" + std::wstring(maskBuf);
22242224 myVerbsMap[verb] = idCmd - idCmdFirst;
22252225 myVerbsMap[verb] = idCmd;
@@ -2241,7 +2241,7 @@
22412241 if (hMenu)
22422242 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp);
22432243 else
2244- exCmds.push_back(CExplorerCommand(static_cast<LPCWSTR>(temp), 0, ShellMenuUnIgnoreCaseSensitiveGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2244+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(static_cast<LPCWSTR>(temp), 0, ShellMenuUnIgnoreCaseSensitiveGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
22452245 std::wstring verb = L"tsvn_" + std::wstring(temp);
22462246 myVerbsMap[verb] = idCmd - idCmdFirst;
22472247 myVerbsMap[verb] = idCmd;
@@ -2264,7 +2264,7 @@
22642264 if (hMenu)
22652265 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, ignorePath);
22662266 else
2267- exCmds.push_back(CExplorerCommand(ignorePath, 0, ShellMenuDeleteIgnore, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2267+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(ignorePath, 0, ShellMenuDeleteIgnore, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
22682268 myIDMap[idCmd - idCmdFirst] = ShellMenuDeleteIgnore;
22692269 myIDMap[idCmd++] = ShellMenuDeleteIgnore;
22702270
@@ -2275,7 +2275,7 @@
22752275 if (hMenu)
22762276 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, maskBuf);
22772277 else
2278- exCmds.push_back(CExplorerCommand(maskBuf, 0, ShellMenuDeleteIgnoreCaseSensitive, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2278+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(maskBuf, 0, ShellMenuDeleteIgnoreCaseSensitive, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
22792279 std::wstring verb = L"tsvn_" + std::wstring(maskBuf);
22802280 myVerbsMap[verb] = idCmd - idCmdFirst;
22812281 myVerbsMap[verb] = idCmd;
@@ -2290,7 +2290,7 @@
22902290 if (hMenu)
22912291 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp);
22922292 else
2293- exCmds.push_back(CExplorerCommand(static_cast<LPCWSTR>(temp), 0, ShellMenuDeleteIgnoreGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2293+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(static_cast<LPCWSTR>(temp), 0, ShellMenuDeleteIgnoreGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
22942294
22952295 myIDMap[idCmd - idCmdFirst] = ShellMenuDeleteIgnoreGlobal;
22962296 myIDMap[idCmd++] = ShellMenuDeleteIgnoreGlobal;
@@ -2303,7 +2303,7 @@
23032303 if (hMenu)
23042304 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp);
23052305 else
2306- exCmds.push_back(CExplorerCommand(maskBuf, 0, ShellMenuDeleteIgnoreCaseSensitiveGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2306+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(maskBuf, 0, ShellMenuDeleteIgnoreCaseSensitiveGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
23072307 std::wstring verb = L"tsvn_" + std::wstring(temp);
23082308 myVerbsMap[verb] = idCmd - idCmdFirst;
23092309 myVerbsMap[verb] = idCmd;
@@ -2318,7 +2318,7 @@
23182318 if (hMenu)
23192319 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, ignorePath);
23202320 else
2321- exCmds.push_back(CExplorerCommand(ignorePath, 0, ShellMenuIgnore, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2321+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(ignorePath, 0, ShellMenuIgnore, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
23222322 myIDMap[idCmd - idCmdFirst] = ShellMenuIgnore;
23232323 myIDMap[idCmd++] = ShellMenuIgnore;
23242324
@@ -2329,7 +2329,7 @@
23292329 if (hMenu)
23302330 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, maskBuf);
23312331 else
2332- exCmds.push_back(CExplorerCommand(maskBuf, 0, ShellMenuIgnoreCaseSensitive, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2332+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(maskBuf, 0, ShellMenuIgnoreCaseSensitive, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
23332333 std::wstring verb = L"tsvn_" + std::wstring(maskBuf);
23342334 myVerbsMap[verb] = idCmd - idCmdFirst;
23352335 myVerbsMap[verb] = idCmd;
@@ -2344,7 +2344,7 @@
23442344 if (hMenu)
23452345 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp);
23462346 else
2347- exCmds.push_back(CExplorerCommand(static_cast<LPCWSTR>(temp), 0, ShellMenuIgnoreGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2347+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(static_cast<LPCWSTR>(temp), 0, ShellMenuIgnoreGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
23482348 myIDMap[idCmd - idCmdFirst] = ShellMenuIgnoreGlobal;
23492349 myIDMap[idCmd++] = ShellMenuIgnoreGlobal;
23502350
@@ -2356,7 +2356,7 @@
23562356 if (hMenu)
23572357 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp);
23582358 else
2359- exCmds.push_back(CExplorerCommand(static_cast<LPCWSTR>(temp), 0, ShellMenuIgnoreCaseSensitiveGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2359+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(static_cast<LPCWSTR>(temp), 0, ShellMenuIgnoreCaseSensitiveGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
23602360 std::wstring verb = L"tsvn_" + std::wstring(temp);
23612361 myVerbsMap[verb] = idCmd - idCmdFirst;
23622362 myVerbsMap[verb] = idCmd;
@@ -2388,7 +2388,7 @@
23882388 if (hMenu)
23892389 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, ignorePath);
23902390 else
2391- exCmds.push_back(CExplorerCommand(ignorePath, 0, ShellMenuDeleteIgnore, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2391+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(ignorePath, 0, ShellMenuDeleteIgnore, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
23922392 std::wstring verb = L"tsvn_" + std::wstring(ignorePath);
23932393 myVerbsMap[verb] = idCmd - idCmdFirst;
23942394 myVerbsMap[verb] = idCmd;
@@ -2410,7 +2410,7 @@
24102410 if (hMenu)
24112411 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, ignorePath);
24122412 else
2413- exCmds.push_back(CExplorerCommand(ignorePath, 0, ShellMenuDeleteIgnoreCaseSensitive, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2413+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(ignorePath, 0, ShellMenuDeleteIgnoreCaseSensitive, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
24142414 verb = std::wstring(ignorePath);
24152415 myVerbsMap[verb] = idCmd - idCmdFirst;
24162416 myVerbsMap[verb] = idCmd;
@@ -2434,7 +2434,7 @@
24342434 if (hMenu)
24352435 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp);
24362436 else
2437- exCmds.push_back(CExplorerCommand(static_cast<LPCWSTR>(temp), 0, ShellMenuDeleteIgnoreCaseSensitiveGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2437+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(static_cast<LPCWSTR>(temp), 0, ShellMenuDeleteIgnoreCaseSensitiveGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
24382438 verb = std::wstring(temp);
24392439 myVerbsMap[verb] = idCmd - idCmdFirst;
24402440 myVerbsMap[verb] = idCmd;
@@ -2458,7 +2458,7 @@
24582458 if (hMenu)
24592459 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, ignorePath);
24602460 else
2461- exCmds.push_back(CExplorerCommand(ignorePath, 0, ShellMenuIgnore, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2461+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(ignorePath, 0, ShellMenuIgnore, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
24622462 std::wstring verb = L"tsvn_" + std::wstring(ignorePath);
24632463 myVerbsMap[verb] = idCmd - idCmdFirst;
24642464 myVerbsMap[verb] = idCmd;
@@ -2480,7 +2480,7 @@
24802480 if (hMenu)
24812481 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, ignorePath);
24822482 else
2483- exCmds.push_back(CExplorerCommand(ignorePath, 0, ShellMenuIgnoreCaseSensitive, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2483+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(ignorePath, 0, ShellMenuIgnoreCaseSensitive, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
24842484 verb = std::wstring(ignorePath);
24852485 myVerbsMap[verb] = idCmd - idCmdFirst;
24862486 myVerbsMap[verb] = idCmd;
@@ -2504,7 +2504,7 @@
25042504 if (hMenu)
25052505 InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp);
25062506 else
2507- exCmds.push_back(CExplorerCommand(static_cast<LPCWSTR>(temp), 0, ShellMenuIgnoreCaseSensitiveGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2507+ exCmds.push_back(Microsoft::WRL::Make<CExplorerCommand>(static_cast<LPCWSTR>(temp), 0, ShellMenuIgnoreCaseSensitiveGlobal, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
25082508 verb = std::wstring(temp);
25092509 myVerbsMap[verb] = idCmd - idCmdFirst;
25102510 myVerbsMap[verb] = idCmd;
@@ -2544,13 +2544,13 @@
25442544 }
25452545 else
25462546 {
2547- m_explorerCommands.push_back(CExplorerCommand(L"", 0, ShellSeparator, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, {}, m_site));
2547+ m_explorerCommands.push_back(Microsoft::WRL::Make<CExplorerCommand>(L"", 0, ShellSeparator, GetAppDirectory(), uuidSource, itemStates, itemStatesFolder, m_files, std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>(), m_site));
25482548 for (const auto& cmd : exCmds)
25492549 {
25502550 m_explorerCommands.push_back(cmd);
25512551 std::wstring prep = stringTableBuffer;
25522552 prep += L": ";
2553- m_explorerCommands.back().PrependTitleWith(prep);
2553+ m_explorerCommands.back()->PrependTitleWith(prep);
25542554 }
25552555 // currently, explorer does not support subcommands which their own subcommands. Once it does,
25562556 // use the line below instead of the ones above
@@ -2837,11 +2837,10 @@
28372837
28382838 HRESULT __stdcall CShellExt::EnumSubCommands(IEnumExplorerCommand** ppEnum)
28392839 {
2840- CTraceToOutputDebugString::Instance()(__FUNCTION__ ": Shell :: EnumSubCommands\n");
2840+ CTraceToOutputDebugString::Instance()(__FUNCTION__ ": Shell :: EnumSubCommands %lld\n", m_explorerCommands.size());
28412841 m_explorerCommands.clear();
28422842 QueryContextMenu(nullptr, 0, 0, 0, CMF_EXTENDEDVERBS | CMF_NORMAL);
2843- *ppEnum = new CExplorerCommandEnum(m_explorerCommands);
2844- (*ppEnum)->AddRef();
2843+ *ppEnum = Microsoft::WRL::Make<CExplorerCommandEnum>(m_explorerCommands).Detach();
28452844 return S_OK;
28462845 }
28472846
@@ -2891,6 +2890,6 @@
28912890 }
28922891 }
28932892 }
2894-
2893+
28952894 return path;
28962895 }
--- trunk/src/TortoiseShell/ExplorerCommand.cpp (revision 29478)
+++ trunk/src/TortoiseShell/ExplorerCommand.cpp (revision 29479)
@@ -19,43 +19,14 @@
1919 #include "stdafx.h"
2020 #include "ExplorerCommand.h"
2121
22-CExplorerCommandEnum::CExplorerCommandEnum(const std::vector<CExplorerCommand> &vec)
23- : m_cRefCount(0)
24- , m_iCur(0)
22+#include "ShellExt.h"
23+
24+CExplorerCommandEnum::CExplorerCommandEnum(const std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>> &vec)
25+ : m_iCur(0)
2526 {
2627 m_vecCommands = vec;
2728 }
2829
29-HRESULT __stdcall CExplorerCommandEnum::QueryInterface(REFIID refiid, void **ppv)
30-{
31- *ppv = nullptr;
32- if (IID_IUnknown == refiid || IID_IEnumExplorerCommand == refiid)
33- *ppv = this;
34-
35- if (*ppv != nullptr)
36- {
37- static_cast<LPUNKNOWN>(*ppv)->AddRef();
38- return S_OK;
39- }
40- return E_NOINTERFACE;
41-}
42-
43-ULONG __stdcall CExplorerCommandEnum::AddRef()
44-{
45- return ++m_cRefCount;
46-}
47-
48-ULONG __stdcall CExplorerCommandEnum::Release()
49-{
50- --m_cRefCount;
51- if (m_cRefCount == 0)
52- {
53- delete this;
54- return 0;
55- }
56- return m_cRefCount;
57-}
58-
5930 HRESULT __stdcall CExplorerCommandEnum::Next(ULONG celt, IExplorerCommand **rgelt, ULONG *pceltFetched)
6031 {
6132 HRESULT hr = S_FALSE;
@@ -71,17 +42,17 @@
7142 if (m_iCur == static_cast<ULONG>(m_vecCommands.size()))
7243 break;
7344
74- rgelt[i] = new CExplorerCommand(m_vecCommands[m_iCur].m_title,
75- m_vecCommands[m_iCur].m_iconId,
76- m_vecCommands[m_iCur].m_cmd,
77- m_vecCommands[m_iCur].m_appDir,
78- m_vecCommands[m_iCur].m_uuidSource,
79- m_vecCommands[m_iCur].m_itemStates,
80- m_vecCommands[m_iCur].m_itemStatesFolder,
81- m_vecCommands[m_iCur].m_paths,
82- m_vecCommands[m_iCur].m_subItems,
83- m_vecCommands[m_iCur].m_site);
84- rgelt[i]->AddRef();
45+ rgelt[i] = Microsoft::WRL::Make<CExplorerCommand>(m_vecCommands[m_iCur]->m_title,
46+ m_vecCommands[m_iCur]->m_iconId,
47+ m_vecCommands[m_iCur]->m_cmd,
48+ m_vecCommands[m_iCur]->m_appDir,
49+ m_vecCommands[m_iCur]->m_uuidSource,
50+ m_vecCommands[m_iCur]->m_itemStates,
51+ m_vecCommands[m_iCur]->m_itemStatesFolder,
52+ m_vecCommands[m_iCur]->m_paths,
53+ m_vecCommands[m_iCur]->m_subItems,
54+ m_vecCommands[m_iCur]->m_site)
55+ .Detach();
8556
8657 if (pceltFetched)
8758 (*pceltFetched)++;
@@ -116,11 +87,10 @@
11687
11788 try
11889 {
119- CExplorerCommandEnum *newEnum = new CExplorerCommandEnum(m_vecCommands);
90+ auto newEnum = Microsoft::WRL::Make<CExplorerCommandEnum>(m_vecCommands);
12091
121- newEnum->AddRef();
12292 newEnum->m_iCur = m_iCur;
123- *ppenum = newEnum;
93+ *ppenum = newEnum.Detach();
12494 }
12595 catch (const std::bad_alloc &)
12696 {
@@ -130,16 +100,15 @@
130100 }
131101
132102 CExplorerCommand::CExplorerCommand(const std::wstring &title, UINT iconId,
133- int cmd,
134- const std::wstring & appDir,
135- const std::wstring & uuidSource,
136- DWORD itemStates,
137- DWORD itemStatesFolder,
138- std::vector<std::wstring> paths,
139- std::vector<CExplorerCommand> subItems,
140- Microsoft::WRL::ComPtr<IUnknown> site)
141- : m_cRefCount(0)
142- , m_title(title)
103+ int cmd,
104+ const std::wstring &appDir,
105+ const std::wstring &uuidSource,
106+ DWORD itemStates,
107+ DWORD itemStatesFolder,
108+ std::vector<std::wstring> paths,
109+ std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>> subItems,
110+ Microsoft::WRL::ComPtr<IUnknown> site)
111+ : m_title(title)
143112 , m_iconId(iconId)
144113 , m_cmd(cmd)
145114 , m_appDir(appDir)
@@ -152,37 +121,6 @@
152121 {
153122 }
154123
155-HRESULT __stdcall CExplorerCommand::QueryInterface(REFIID refiid, void **ppv)
156-{
157- *ppv = nullptr;
158- if (IID_IUnknown == refiid || IID_IExplorerCommand == refiid)
159- *ppv = this;
160-
161- if (*ppv != nullptr)
162- {
163- static_cast<LPUNKNOWN>(*ppv)->AddRef();
164- return S_OK;
165- }
166- return E_NOINTERFACE;
167-}
168-
169-ULONG __stdcall CExplorerCommand::AddRef()
170-{
171- return ++m_cRefCount;
172-}
173-
174-ULONG __stdcall CExplorerCommand::Release()
175-{
176- --m_cRefCount;
177- if (m_cRefCount == 0)
178- {
179- CTraceToOutputDebugString::Instance()( L"refcount zero: title: %s\n", m_title.c_str());
180- delete this;
181- return 0;
182- }
183- return m_cRefCount;
184-}
185-
186124 HRESULT __stdcall CExplorerCommand::GetTitle(IShellItemArray * /*psiItemArray*/, LPWSTR *ppszName)
187125 {
188126 CTraceToOutputDebugString::Instance()(__FUNCTION__ L": title: %s\n", m_title.c_str());
@@ -209,7 +147,7 @@
209147 return S_OK;
210148 }
211149
212-HRESULT __stdcall CExplorerCommand::GetToolTip(IShellItemArray * /*psiItemArray*/, LPWSTR * ppszInfotip)
150+HRESULT __stdcall CExplorerCommand::GetToolTip(IShellItemArray * /*psiItemArray*/, LPWSTR *ppszInfotip)
213151 {
214152 CTraceToOutputDebugString::Instance()(__FUNCTION__ L": title: %s\n", m_title.c_str());
215153 *ppszInfotip = nullptr;
@@ -279,8 +217,7 @@
279217 CTraceToOutputDebugString::Instance()(__FUNCTION__ L": title: %s\n", m_title.c_str());
280218 if (m_subItems.empty())
281219 return E_NOTIMPL;
282- *ppEnum = new CExplorerCommandEnum(m_subItems);
283- (*ppEnum)->AddRef();
220+ *ppEnum = Microsoft::WRL::Make<CExplorerCommandEnum>(m_subItems).Detach();
284221 return S_OK;
285222 }
286223
--- trunk/src/TortoiseShell/ExplorerCommand.h (revision 29478)
+++ trunk/src/TortoiseShell/ExplorerCommand.h (revision 29479)
@@ -18,21 +18,18 @@
1818 //
1919 #pragma once
2020 #include <Shobjidl.h>
21-#include "ShellExt.h"
21+#include <wrl/module.h>
22+#include <wrl/implements.h>
23+#include <wrl/client.h>
24+#include <shobjidl_core.h>
2225
2326 class CExplorerCommand;
2427
25-class CExplorerCommandEnum : public IEnumExplorerCommand
28+class CExplorerCommandEnum : public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::WinRtClassicComMix | Microsoft::WRL::InhibitRoOriginateError>, IEnumExplorerCommand>
2629 {
2730 public:
28- explicit CExplorerCommandEnum(const std::vector<CExplorerCommand>& vec);
29- virtual ~CExplorerCommandEnum() = default;
31+ explicit CExplorerCommandEnum(const std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>& vec);
3032
31- // IUnknown members
32- HRESULT __stdcall QueryInterface(REFIID, void**) override;
33- ULONG __stdcall AddRef() override;
34- ULONG __stdcall Release() override;
35-
3633 // IEnumExplorerCommand members
3734 HRESULT __stdcall Next(ULONG, IExplorerCommand**, ULONG*) override;
3835 HRESULT __stdcall Skip(ULONG) override;
@@ -40,35 +37,27 @@
4037 HRESULT __stdcall Clone(IEnumExplorerCommand**) override;
4138
4239 private:
43- std::vector<CExplorerCommand> m_vecCommands;
44- ULONG m_cRefCount;
45- size_t m_iCur;
40+ std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>> m_vecCommands;
41+ size_t m_iCur;
4642 };
4743
48-class __declspec(uuid("30351351-7B7D-4FCC-81B4-1E394CA267EB")) CExplorerCommand : public IExplorerCommand
49- , IObjectWithSite
44+class CExplorerCommand : public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::WinRtClassicComMix | Microsoft::WRL::InhibitRoOriginateError>, IExplorerCommand, IObjectWithSite>
5045 {
5146 friend class CExplorerCommandEnum;
5247
5348 public:
5449 explicit CExplorerCommand(const std::wstring& title, UINT iconId,
55- int cmd,
56- const std::wstring& appDir,
57- const std::wstring& uuidSource,
58- DWORD itemStates,
59- DWORD itemStatesFolder,
60- std::vector<std::wstring> paths,
61- std::vector<CExplorerCommand> subItems,
62- Microsoft::WRL::ComPtr<IUnknown> site);
63-
64- virtual ~CExplorerCommand() = default;
50+ int cmd,
51+ const std::wstring& appDir,
52+ const std::wstring& uuidSource,
53+ DWORD itemStates,
54+ DWORD itemStatesFolder,
55+ std::vector<std::wstring> paths,
56+ std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>> subItems,
57+ Microsoft::WRL::ComPtr<IUnknown> site);
58+ CExplorerCommand() = delete;
6559 void PrependTitleWith(const std::wstring& prep) { m_title = prep + m_title; }
6660
67- // IUnknown members
68- HRESULT __stdcall QueryInterface(REFIID, void**) override;
69- ULONG __stdcall AddRef() override;
70- ULONG __stdcall Release() override;
71-
7261 // Inherited via IExplorerCommand
7362 HRESULT __stdcall GetTitle(IShellItemArray* psiItemArray, LPWSTR* ppszName) override;
7463 HRESULT __stdcall GetIcon(IShellItemArray* psiItemArray, LPWSTR* ppszIcon) override;
@@ -84,16 +73,14 @@
8473 HRESULT __stdcall GetSite(REFIID riid, void** ppvSite) override;
8574
8675 private:
87- ULONG m_cRefCount;
88-
89- std::wstring m_title;
90- UINT m_iconId = 0;
91- int m_cmd = 0;
92- std::wstring m_appDir;
93- std::wstring m_uuidSource;
94- DWORD m_itemStates = 0;
95- DWORD m_itemStatesFolder = 0;
96- std::vector<std::wstring> m_paths;
97- std::vector<CExplorerCommand> m_subItems;
98- Microsoft::WRL::ComPtr<IUnknown> m_site;
76+ std::wstring m_title;
77+ UINT m_iconId = 0;
78+ int m_cmd = 0;
79+ std::wstring m_appDir;
80+ std::wstring m_uuidSource;
81+ DWORD m_itemStates = 0;
82+ DWORD m_itemStatesFolder = 0;
83+ std::vector<std::wstring> m_paths;
84+ std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>> m_subItems;
85+ Microsoft::WRL::ComPtr<IUnknown> m_site;
9986 };
\ No newline at end of file
--- trunk/src/TortoiseShell/ShellExt.h (revision 29478)
+++ trunk/src/TortoiseShell/ShellExt.h (revision 29479)
@@ -77,7 +77,7 @@
7777 , IObjectWithSite
7878 {
7979 public:
80- enum SVNCommands
80+ enum SVNCommands : int
8181 {
8282 ShellSeparator = 0,
8383 ShellSubMenu = 1,
@@ -187,43 +187,43 @@
187187 std::wstring verb;
188188 };
189189
190- static MenuInfo menuInfo[];
191- FileState m_state;
192- volatile ULONG m_cRef;
193- //std::map<int,std::string> verbMap;
194- std::map<UINT_PTR, UINT_PTR> myIDMap;
195- std::map<UINT_PTR, UINT_PTR> mySubMenuMap;
196- std::map<std::wstring, UINT_PTR> myVerbsMap;
197- std::map<UINT_PTR, std::wstring> myVerbsIDMap;
198- std::wstring m_folder;
199- std::vector<std::wstring> m_files;
200- std::vector<std::wstring> m_urls;
201- DWORD itemStates; ///< see the globals.h file for the ITEMIS_* defines
202- DWORD itemStatesFolder; ///< used for states of the folder_ (folder background and/or drop target folder)
203- std::wstring uuidSource;
204- std::wstring uuidTarget;
205- int space;
206- wchar_t stringTableBuffer[255];
207- std::wstring mainColumnFilePath; ///< holds the last file/dir path for the column provider
208- std::wstring extraColumnFilePath; ///< holds the last file/dir path for the column provider
209- std::wstring columnAuthor; ///< holds the corresponding author of the file/dir above
210- std::wstring itemUrl;
211- std::wstring itemShortUrl;
212- std::wstring ignoredProps;
213- std::wstring ignoredGlobalProps;
214- std::wstring owner;
215- svn_revnum_t columnRev; ///< holds the corresponding revision to the file/dir above
216- svn_wc_status_kind fileStatus;
217- CRegStdString regDiffLater;
218- Microsoft::WRL::ComPtr<IUnknown> m_site;
190+ static MenuInfo menuInfo[];
191+ FileState m_state;
192+ volatile ULONG m_cRef;
193+ // std::map<int,std::string> verbMap;
194+ std::map<UINT_PTR, UINT_PTR> myIDMap;
195+ std::map<UINT_PTR, UINT_PTR> mySubMenuMap;
196+ std::map<std::wstring, UINT_PTR> myVerbsMap;
197+ std::map<UINT_PTR, std::wstring> myVerbsIDMap;
198+ std::wstring m_folder;
199+ std::vector<std::wstring> m_files;
200+ std::vector<std::wstring> m_urls;
201+ DWORD itemStates; ///< see the globals.h file for the ITEMIS_* defines
202+ DWORD itemStatesFolder; ///< used for states of the folder_ (folder background and/or drop target folder)
203+ std::wstring uuidSource;
204+ std::wstring uuidTarget;
205+ int space;
206+ wchar_t stringTableBuffer[255];
207+ std::wstring mainColumnFilePath; ///< holds the last file/dir path for the column provider
208+ std::wstring extraColumnFilePath; ///< holds the last file/dir path for the column provider
209+ std::wstring columnAuthor; ///< holds the corresponding author of the file/dir above
210+ std::wstring itemUrl;
211+ std::wstring itemShortUrl;
212+ std::wstring ignoredProps;
213+ std::wstring ignoredGlobalProps;
214+ std::wstring owner;
215+ svn_revnum_t columnRev; ///< holds the corresponding revision to the file/dir above
216+ svn_wc_status_kind fileStatus;
217+ CRegStdString regDiffLater;
218+ Microsoft::WRL::ComPtr<IUnknown> m_site;
219219
220- SVNFolderStatus m_cachedStatus; // status cache
221- CRemoteCacheLink m_remoteCacheLink;
222- IconBitmapUtils m_iconBitmapUtils;
220+ SVNFolderStatus m_cachedStatus; // status cache
221+ CRemoteCacheLink m_remoteCacheLink;
222+ IconBitmapUtils m_iconBitmapUtils;
223223
224- CString columnFolder; ///< current folder of ColumnProvider
225- std::vector<std::pair<std::wstring, std::string>> columnUserProps; ///< user properties of ColumnProvider
226- std::vector<CExplorerCommand> m_explorerCommands;
224+ CString columnFolder; ///< current folder of ColumnProvider
225+ std::vector<std::pair<std::wstring, std::string>> columnUserProps; ///< user properties of ColumnProvider
226+ std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>> m_explorerCommands;
227227
228228 #define MAKESTRING(ID) LoadStringEx(g_hResInst, ID, stringTableBuffer, _countof(stringTableBuffer), (WORD)CRegStdDWORD(L"Software\\TortoiseSVN\\LanguageID", MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)))
229229 private:
Afficher sur ancien navigateur de dépôt.