Révision | 29479 (tree) |
---|---|
l'heure | 2022-11-19 00:16:19 |
Auteur | stefankueng |
implement the CExplorerCommand as a WinRT Runtime component to work around an issue with the explorer context menu
@@ -4,6 +4,8 @@ | ||
4 | 4 | used the wrong path. (Stefan) |
5 | 5 | - BUG: the revision graph did not show the HEAD revision |
6 | 6 | 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 | |
7 | 9 | |
8 | 10 | Version 1.14.5 |
9 | 11 | - BUG: 1.14.4 was wrongly linked against svn 1.14.1 |
@@ -807,7 +807,7 @@ | ||
807 | 807 | if (menu) |
808 | 808 | InsertMenuItem(menu, pos, TRUE, &menuItemInfo); |
809 | 809 | 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)); | |
811 | 811 | |
812 | 812 | myVerbsMap[verb] = id - idCmdFirst; |
813 | 813 | myVerbsMap[verb] = id; |
@@ -1173,7 +1173,7 @@ | ||
1173 | 1173 | if (subMenu) |
1174 | 1174 | InsertMenu(subMenu, indexSubMenu++, MF_SEPARATOR | MF_BYPOSITION, 0, nullptr); |
1175 | 1175 | 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)); | |
1177 | 1177 | idCmd++; |
1178 | 1178 | } |
1179 | 1179 |
@@ -1802,7 +1802,7 @@ | ||
1802 | 1802 | break; |
1803 | 1803 | default: |
1804 | 1804 | break; |
1805 | - //#endregion | |
1805 | + // #endregion | |
1806 | 1806 | } // switch (id_it->second) |
1807 | 1807 | if (!svnCmd.empty()) |
1808 | 1808 | { |
@@ -2123,12 +2123,12 @@ | ||
2123 | 2123 | unsigned __int64 topMenu, |
2124 | 2124 | bool bShowIcons) |
2125 | 2125 | { |
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; | |
2132 | 2132 | |
2133 | 2133 | if (m_files.empty()) |
2134 | 2134 | return; |
@@ -2163,7 +2163,7 @@ | ||
2163 | 2163 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, ignorePath); |
2164 | 2164 | } |
2165 | 2165 | 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)); | |
2167 | 2167 | std::wstring verb = L"tsvn_" + std::wstring(ignorePath); |
2168 | 2168 | myVerbsMap[verb] = idCmd - idCmdFirst; |
2169 | 2169 | myVerbsMap[verb] = idCmd; |
@@ -2194,7 +2194,7 @@ | ||
2194 | 2194 | if (hMenu) |
2195 | 2195 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp); |
2196 | 2196 | 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)); | |
2198 | 2198 | std::wstring verb = L"tsvn_" + std::wstring(temp); |
2199 | 2199 | myVerbsMap[verb] = idCmd - idCmdFirst; |
2200 | 2200 | myVerbsMap[verb] = idCmd; |
@@ -2219,7 +2219,7 @@ | ||
2219 | 2219 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, maskBuf); |
2220 | 2220 | } |
2221 | 2221 | 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)); | |
2223 | 2223 | std::wstring verb = L"tsvn_" + std::wstring(maskBuf); |
2224 | 2224 | myVerbsMap[verb] = idCmd - idCmdFirst; |
2225 | 2225 | myVerbsMap[verb] = idCmd; |
@@ -2241,7 +2241,7 @@ | ||
2241 | 2241 | if (hMenu) |
2242 | 2242 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp); |
2243 | 2243 | 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)); | |
2245 | 2245 | std::wstring verb = L"tsvn_" + std::wstring(temp); |
2246 | 2246 | myVerbsMap[verb] = idCmd - idCmdFirst; |
2247 | 2247 | myVerbsMap[verb] = idCmd; |
@@ -2264,7 +2264,7 @@ | ||
2264 | 2264 | if (hMenu) |
2265 | 2265 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, ignorePath); |
2266 | 2266 | 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)); | |
2268 | 2268 | myIDMap[idCmd - idCmdFirst] = ShellMenuDeleteIgnore; |
2269 | 2269 | myIDMap[idCmd++] = ShellMenuDeleteIgnore; |
2270 | 2270 |
@@ -2275,7 +2275,7 @@ | ||
2275 | 2275 | if (hMenu) |
2276 | 2276 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, maskBuf); |
2277 | 2277 | 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)); | |
2279 | 2279 | std::wstring verb = L"tsvn_" + std::wstring(maskBuf); |
2280 | 2280 | myVerbsMap[verb] = idCmd - idCmdFirst; |
2281 | 2281 | myVerbsMap[verb] = idCmd; |
@@ -2290,7 +2290,7 @@ | ||
2290 | 2290 | if (hMenu) |
2291 | 2291 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp); |
2292 | 2292 | 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)); | |
2294 | 2294 | |
2295 | 2295 | myIDMap[idCmd - idCmdFirst] = ShellMenuDeleteIgnoreGlobal; |
2296 | 2296 | myIDMap[idCmd++] = ShellMenuDeleteIgnoreGlobal; |
@@ -2303,7 +2303,7 @@ | ||
2303 | 2303 | if (hMenu) |
2304 | 2304 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp); |
2305 | 2305 | 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)); | |
2307 | 2307 | std::wstring verb = L"tsvn_" + std::wstring(temp); |
2308 | 2308 | myVerbsMap[verb] = idCmd - idCmdFirst; |
2309 | 2309 | myVerbsMap[verb] = idCmd; |
@@ -2318,7 +2318,7 @@ | ||
2318 | 2318 | if (hMenu) |
2319 | 2319 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, ignorePath); |
2320 | 2320 | 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)); | |
2322 | 2322 | myIDMap[idCmd - idCmdFirst] = ShellMenuIgnore; |
2323 | 2323 | myIDMap[idCmd++] = ShellMenuIgnore; |
2324 | 2324 |
@@ -2329,7 +2329,7 @@ | ||
2329 | 2329 | if (hMenu) |
2330 | 2330 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, maskBuf); |
2331 | 2331 | 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)); | |
2333 | 2333 | std::wstring verb = L"tsvn_" + std::wstring(maskBuf); |
2334 | 2334 | myVerbsMap[verb] = idCmd - idCmdFirst; |
2335 | 2335 | myVerbsMap[verb] = idCmd; |
@@ -2344,7 +2344,7 @@ | ||
2344 | 2344 | if (hMenu) |
2345 | 2345 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp); |
2346 | 2346 | 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)); | |
2348 | 2348 | myIDMap[idCmd - idCmdFirst] = ShellMenuIgnoreGlobal; |
2349 | 2349 | myIDMap[idCmd++] = ShellMenuIgnoreGlobal; |
2350 | 2350 |
@@ -2356,7 +2356,7 @@ | ||
2356 | 2356 | if (hMenu) |
2357 | 2357 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp); |
2358 | 2358 | 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)); | |
2360 | 2360 | std::wstring verb = L"tsvn_" + std::wstring(temp); |
2361 | 2361 | myVerbsMap[verb] = idCmd - idCmdFirst; |
2362 | 2362 | myVerbsMap[verb] = idCmd; |
@@ -2388,7 +2388,7 @@ | ||
2388 | 2388 | if (hMenu) |
2389 | 2389 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, ignorePath); |
2390 | 2390 | 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)); | |
2392 | 2392 | std::wstring verb = L"tsvn_" + std::wstring(ignorePath); |
2393 | 2393 | myVerbsMap[verb] = idCmd - idCmdFirst; |
2394 | 2394 | myVerbsMap[verb] = idCmd; |
@@ -2410,7 +2410,7 @@ | ||
2410 | 2410 | if (hMenu) |
2411 | 2411 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, ignorePath); |
2412 | 2412 | 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)); | |
2414 | 2414 | verb = std::wstring(ignorePath); |
2415 | 2415 | myVerbsMap[verb] = idCmd - idCmdFirst; |
2416 | 2416 | myVerbsMap[verb] = idCmd; |
@@ -2434,7 +2434,7 @@ | ||
2434 | 2434 | if (hMenu) |
2435 | 2435 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp); |
2436 | 2436 | 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)); | |
2438 | 2438 | verb = std::wstring(temp); |
2439 | 2439 | myVerbsMap[verb] = idCmd - idCmdFirst; |
2440 | 2440 | myVerbsMap[verb] = idCmd; |
@@ -2458,7 +2458,7 @@ | ||
2458 | 2458 | if (hMenu) |
2459 | 2459 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, ignorePath); |
2460 | 2460 | 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)); | |
2462 | 2462 | std::wstring verb = L"tsvn_" + std::wstring(ignorePath); |
2463 | 2463 | myVerbsMap[verb] = idCmd - idCmdFirst; |
2464 | 2464 | myVerbsMap[verb] = idCmd; |
@@ -2480,7 +2480,7 @@ | ||
2480 | 2480 | if (hMenu) |
2481 | 2481 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, ignorePath); |
2482 | 2482 | 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)); | |
2484 | 2484 | verb = std::wstring(ignorePath); |
2485 | 2485 | myVerbsMap[verb] = idCmd - idCmdFirst; |
2486 | 2486 | myVerbsMap[verb] = idCmd; |
@@ -2504,7 +2504,7 @@ | ||
2504 | 2504 | if (hMenu) |
2505 | 2505 | InsertMenu(ignoreSubMenu, indexIgnoreSub++, MF_BYPOSITION | MF_STRING, idCmd, temp); |
2506 | 2506 | 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)); | |
2508 | 2508 | verb = std::wstring(temp); |
2509 | 2509 | myVerbsMap[verb] = idCmd - idCmdFirst; |
2510 | 2510 | myVerbsMap[verb] = idCmd; |
@@ -2544,13 +2544,13 @@ | ||
2544 | 2544 | } |
2545 | 2545 | else |
2546 | 2546 | { |
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)); | |
2548 | 2548 | for (const auto& cmd : exCmds) |
2549 | 2549 | { |
2550 | 2550 | m_explorerCommands.push_back(cmd); |
2551 | 2551 | std::wstring prep = stringTableBuffer; |
2552 | 2552 | prep += L": "; |
2553 | - m_explorerCommands.back().PrependTitleWith(prep); | |
2553 | + m_explorerCommands.back()->PrependTitleWith(prep); | |
2554 | 2554 | } |
2555 | 2555 | // currently, explorer does not support subcommands which their own subcommands. Once it does, |
2556 | 2556 | // use the line below instead of the ones above |
@@ -2837,11 +2837,10 @@ | ||
2837 | 2837 | |
2838 | 2838 | HRESULT __stdcall CShellExt::EnumSubCommands(IEnumExplorerCommand** ppEnum) |
2839 | 2839 | { |
2840 | - CTraceToOutputDebugString::Instance()(__FUNCTION__ ": Shell :: EnumSubCommands\n"); | |
2840 | + CTraceToOutputDebugString::Instance()(__FUNCTION__ ": Shell :: EnumSubCommands %lld\n", m_explorerCommands.size()); | |
2841 | 2841 | m_explorerCommands.clear(); |
2842 | 2842 | 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(); | |
2845 | 2844 | return S_OK; |
2846 | 2845 | } |
2847 | 2846 |
@@ -2891,6 +2890,6 @@ | ||
2891 | 2890 | } |
2892 | 2891 | } |
2893 | 2892 | } |
2894 | - | |
2893 | + | |
2895 | 2894 | return path; |
2896 | 2895 | } |
@@ -19,43 +19,14 @@ | ||
19 | 19 | #include "stdafx.h" |
20 | 20 | #include "ExplorerCommand.h" |
21 | 21 | |
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) | |
25 | 26 | { |
26 | 27 | m_vecCommands = vec; |
27 | 28 | } |
28 | 29 | |
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 | - | |
59 | 30 | HRESULT __stdcall CExplorerCommandEnum::Next(ULONG celt, IExplorerCommand **rgelt, ULONG *pceltFetched) |
60 | 31 | { |
61 | 32 | HRESULT hr = S_FALSE; |
@@ -71,17 +42,17 @@ | ||
71 | 42 | if (m_iCur == static_cast<ULONG>(m_vecCommands.size())) |
72 | 43 | break; |
73 | 44 | |
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(); | |
85 | 56 | |
86 | 57 | if (pceltFetched) |
87 | 58 | (*pceltFetched)++; |
@@ -116,11 +87,10 @@ | ||
116 | 87 | |
117 | 88 | try |
118 | 89 | { |
119 | - CExplorerCommandEnum *newEnum = new CExplorerCommandEnum(m_vecCommands); | |
90 | + auto newEnum = Microsoft::WRL::Make<CExplorerCommandEnum>(m_vecCommands); | |
120 | 91 | |
121 | - newEnum->AddRef(); | |
122 | 92 | newEnum->m_iCur = m_iCur; |
123 | - *ppenum = newEnum; | |
93 | + *ppenum = newEnum.Detach(); | |
124 | 94 | } |
125 | 95 | catch (const std::bad_alloc &) |
126 | 96 | { |
@@ -130,16 +100,15 @@ | ||
130 | 100 | } |
131 | 101 | |
132 | 102 | 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) | |
143 | 112 | , m_iconId(iconId) |
144 | 113 | , m_cmd(cmd) |
145 | 114 | , m_appDir(appDir) |
@@ -152,37 +121,6 @@ | ||
152 | 121 | { |
153 | 122 | } |
154 | 123 | |
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 | - | |
186 | 124 | HRESULT __stdcall CExplorerCommand::GetTitle(IShellItemArray * /*psiItemArray*/, LPWSTR *ppszName) |
187 | 125 | { |
188 | 126 | CTraceToOutputDebugString::Instance()(__FUNCTION__ L": title: %s\n", m_title.c_str()); |
@@ -209,7 +147,7 @@ | ||
209 | 147 | return S_OK; |
210 | 148 | } |
211 | 149 | |
212 | -HRESULT __stdcall CExplorerCommand::GetToolTip(IShellItemArray * /*psiItemArray*/, LPWSTR * ppszInfotip) | |
150 | +HRESULT __stdcall CExplorerCommand::GetToolTip(IShellItemArray * /*psiItemArray*/, LPWSTR *ppszInfotip) | |
213 | 151 | { |
214 | 152 | CTraceToOutputDebugString::Instance()(__FUNCTION__ L": title: %s\n", m_title.c_str()); |
215 | 153 | *ppszInfotip = nullptr; |
@@ -279,8 +217,7 @@ | ||
279 | 217 | CTraceToOutputDebugString::Instance()(__FUNCTION__ L": title: %s\n", m_title.c_str()); |
280 | 218 | if (m_subItems.empty()) |
281 | 219 | return E_NOTIMPL; |
282 | - *ppEnum = new CExplorerCommandEnum(m_subItems); | |
283 | - (*ppEnum)->AddRef(); | |
220 | + *ppEnum = Microsoft::WRL::Make<CExplorerCommandEnum>(m_subItems).Detach(); | |
284 | 221 | return S_OK; |
285 | 222 | } |
286 | 223 |
@@ -18,21 +18,18 @@ | ||
18 | 18 | // |
19 | 19 | #pragma once |
20 | 20 | #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> | |
22 | 25 | |
23 | 26 | class CExplorerCommand; |
24 | 27 | |
25 | -class CExplorerCommandEnum : public IEnumExplorerCommand | |
28 | +class CExplorerCommandEnum : public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::WinRtClassicComMix | Microsoft::WRL::InhibitRoOriginateError>, IEnumExplorerCommand> | |
26 | 29 | { |
27 | 30 | public: |
28 | - explicit CExplorerCommandEnum(const std::vector<CExplorerCommand>& vec); | |
29 | - virtual ~CExplorerCommandEnum() = default; | |
31 | + explicit CExplorerCommandEnum(const std::vector<Microsoft::WRL::ComPtr<CExplorerCommand>>& vec); | |
30 | 32 | |
31 | - // IUnknown members | |
32 | - HRESULT __stdcall QueryInterface(REFIID, void**) override; | |
33 | - ULONG __stdcall AddRef() override; | |
34 | - ULONG __stdcall Release() override; | |
35 | - | |
36 | 33 | // IEnumExplorerCommand members |
37 | 34 | HRESULT __stdcall Next(ULONG, IExplorerCommand**, ULONG*) override; |
38 | 35 | HRESULT __stdcall Skip(ULONG) override; |
@@ -40,35 +37,27 @@ | ||
40 | 37 | HRESULT __stdcall Clone(IEnumExplorerCommand**) override; |
41 | 38 | |
42 | 39 | 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; | |
46 | 42 | }; |
47 | 43 | |
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> | |
50 | 45 | { |
51 | 46 | friend class CExplorerCommandEnum; |
52 | 47 | |
53 | 48 | public: |
54 | 49 | 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; | |
65 | 59 | void PrependTitleWith(const std::wstring& prep) { m_title = prep + m_title; } |
66 | 60 | |
67 | - // IUnknown members | |
68 | - HRESULT __stdcall QueryInterface(REFIID, void**) override; | |
69 | - ULONG __stdcall AddRef() override; | |
70 | - ULONG __stdcall Release() override; | |
71 | - | |
72 | 61 | // Inherited via IExplorerCommand |
73 | 62 | HRESULT __stdcall GetTitle(IShellItemArray* psiItemArray, LPWSTR* ppszName) override; |
74 | 63 | HRESULT __stdcall GetIcon(IShellItemArray* psiItemArray, LPWSTR* ppszIcon) override; |
@@ -84,16 +73,14 @@ | ||
84 | 73 | HRESULT __stdcall GetSite(REFIID riid, void** ppvSite) override; |
85 | 74 | |
86 | 75 | 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; | |
99 | 86 | }; |
\ No newline at end of file |
@@ -77,7 +77,7 @@ | ||
77 | 77 | , IObjectWithSite |
78 | 78 | { |
79 | 79 | public: |
80 | - enum SVNCommands | |
80 | + enum SVNCommands : int | |
81 | 81 | { |
82 | 82 | ShellSeparator = 0, |
83 | 83 | ShellSubMenu = 1, |
@@ -187,43 +187,43 @@ | ||
187 | 187 | std::wstring verb; |
188 | 188 | }; |
189 | 189 | |
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; | |
219 | 219 | |
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; | |
223 | 223 | |
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; | |
227 | 227 | |
228 | 228 | #define MAKESTRING(ID) LoadStringEx(g_hResInst, ID, stringTableBuffer, _countof(stringTableBuffer), (WORD)CRegStdDWORD(L"Software\\TortoiseSVN\\LanguageID", MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))) |
229 | 229 | private: |