Skip to content

Commit 709270b

Browse files
authored
Disable mutex in shell extension. (#117)
Instead, we confirm that key deletion or insertion during enumeration produces weird behaviour, but should not crash. Fixes #115
1 parent e5a9ef5 commit 709270b

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

src/pyshellext/shellext.cpp

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ class PyManagerOperationInProgress
373373
class DECLSPEC_UUID(CLSID_IDLE_COMMAND) IdleCommand
374374
: public RuntimeClass<RuntimeClassFlags<ClassicCom>, IExplorerCommand, IObjectWithSite>
375375
{
376-
PyManagerOperationInProgress busy;
377376
std::vector<IdleData> idles;
378377
std::wstring iconPath;
379378
std::wstring title;
@@ -392,21 +391,19 @@ class DECLSPEC_UUID(CLSID_IDLE_COMMAND) IdleCommand
392391
iconPath += L",-4";
393392
}
394393

395-
if (!busy) {
396-
hr = ReadAllIdleInstalls(idles, HKEY_LOCAL_MACHINE, L"Software\\Python", KEY_WOW64_32KEY);
397-
if (SUCCEEDED(hr)) {
398-
hr = ReadAllIdleInstalls(idles, HKEY_LOCAL_MACHINE, L"Software\\Python", KEY_WOW64_64KEY);
399-
}
400-
if (SUCCEEDED(hr)) {
401-
hr = ReadAllIdleInstalls(idles, HKEY_CURRENT_USER, L"Software\\Python", 0);
402-
}
394+
hr = ReadAllIdleInstalls(idles, HKEY_LOCAL_MACHINE, L"Software\\Python", KEY_WOW64_32KEY);
395+
if (SUCCEEDED(hr)) {
396+
hr = ReadAllIdleInstalls(idles, HKEY_LOCAL_MACHINE, L"Software\\Python", KEY_WOW64_64KEY);
397+
}
398+
if (SUCCEEDED(hr)) {
399+
hr = ReadAllIdleInstalls(idles, HKEY_CURRENT_USER, L"Software\\Python", 0);
400+
}
403401

404-
if (FAILED(hr)) {
405-
wchar_t buffer[512];
406-
swprintf_s(buffer, L"IdleCommand error 0x%08X", (DWORD)hr);
407-
OutputDebugStringW(buffer);
408-
idles.clear();
409-
}
402+
if (FAILED(hr)) {
403+
wchar_t buffer[512];
404+
swprintf_s(buffer, L"IdleCommand error 0x%08X", (DWORD)hr);
405+
OutputDebugStringW(buffer);
406+
idles.clear();
410407
}
411408
}
412409

@@ -425,12 +422,10 @@ class DECLSPEC_UUID(CLSID_IDLE_COMMAND) IdleCommand
425422
iconPath += L",-4";
426423
}
427424

428-
if (!busy) {
429-
hr = ReadAllIdleInstalls(idles, hive, root, 0);
425+
hr = ReadAllIdleInstalls(idles, hive, root, 0);
430426

431-
if (FAILED(hr)) {
432-
idles.clear();
433-
}
427+
if (FAILED(hr)) {
428+
idles.clear();
434429
}
435430
}
436431
#endif
@@ -469,6 +464,10 @@ class DECLSPEC_UUID(CLSID_IDLE_COMMAND) IdleCommand
469464

470465
IFACEMETHODIMP GetState(IShellItemArray *psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE *pCmdState)
471466
{
467+
if (title.empty()) {
468+
*pCmdState = ECS_HIDDEN;
469+
return S_OK;
470+
}
472471
*pCmdState = idles.size() ? ECS_ENABLED : ECS_DISABLED;
473472
return S_OK;
474473
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy