Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/manage/install_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ def _fatal_install_error(cmd, ex):
def execute(cmd):
LOGGER.debug("BEGIN install_command.execute: %r", cmd.args)

cmd.tags = []

if cmd.refresh:
if cmd.args:
LOGGER.warn("Ignoring arguments; --refresh always refreshes all installs.")
Expand All @@ -580,7 +582,6 @@ def execute(cmd):
download_index = {"versions": []}

if not cmd.by_id:
cmd.tags = []
for arg in cmd.args:
if arg.casefold() == "default".casefold():
LOGGER.debug("Replacing 'default' with '%s'", cmd.default_tag)
Expand Down
72 changes: 56 additions & 16 deletions src/pyshellext/shellext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,45 @@ class DECLSPEC_UUID(CLSID_COMMAND_ENUMERATOR) CommandEnumerator
};


class PyManagerOperationInProgress
{
HANDLE hGlobalSem;
bool busy;

bool _create() {
hGlobalSem = CreateSemaphoreExW(NULL, 0, 1,
L"PyManager-OperationInProgress", 0, SEMAPHORE_MODIFY_STATE | SYNCHRONIZE);

return (hGlobalSem && GetLastError() != ERROR_ALREADY_EXISTS);
}

public:
PyManagerOperationInProgress()
{
busy = _create();
}

~PyManagerOperationInProgress()
{
if (hGlobalSem) {
if (!busy) {
ReleaseSemaphore(hGlobalSem, 1, NULL);
}
CloseHandle(hGlobalSem);
}
}

operator bool()
{
return hGlobalSem && !busy;
}
};


class DECLSPEC_UUID(CLSID_IDLE_COMMAND) IdleCommand
: public RuntimeClass<RuntimeClassFlags<ClassicCom>, IExplorerCommand, IObjectWithSite>
{
PyManagerOperationInProgress busy;
std::vector<IdleData> idles;
std::wstring iconPath;
std::wstring title;
Expand All @@ -356,19 +392,21 @@ class DECLSPEC_UUID(CLSID_IDLE_COMMAND) IdleCommand
iconPath += L",-4";
}

hr = ReadAllIdleInstalls(idles, HKEY_LOCAL_MACHINE, L"Software\\Python", KEY_WOW64_32KEY);
if (SUCCEEDED(hr)) {
hr = ReadAllIdleInstalls(idles, HKEY_LOCAL_MACHINE, L"Software\\Python", KEY_WOW64_64KEY);
}
if (SUCCEEDED(hr)) {
hr = ReadAllIdleInstalls(idles, HKEY_CURRENT_USER, L"Software\\Python", 0);
}
if (!busy) {
hr = ReadAllIdleInstalls(idles, HKEY_LOCAL_MACHINE, L"Software\\Python", KEY_WOW64_32KEY);
if (SUCCEEDED(hr)) {
hr = ReadAllIdleInstalls(idles, HKEY_LOCAL_MACHINE, L"Software\\Python", KEY_WOW64_64KEY);
}
if (SUCCEEDED(hr)) {
hr = ReadAllIdleInstalls(idles, HKEY_CURRENT_USER, L"Software\\Python", 0);
}

if (FAILED(hr)) {
wchar_t buffer[512];
swprintf_s(buffer, L"IdleCommand error 0x%08X", (DWORD)hr);
OutputDebugStringW(buffer);
idles.clear();
if (FAILED(hr)) {
wchar_t buffer[512];
swprintf_s(buffer, L"IdleCommand error 0x%08X", (DWORD)hr);
OutputDebugStringW(buffer);
idles.clear();
}
}
}

Expand All @@ -387,10 +425,12 @@ class DECLSPEC_UUID(CLSID_IDLE_COMMAND) IdleCommand
iconPath += L",-4";
}

hr = ReadAllIdleInstalls(idles, hive, root, 0);
if (!busy) {
hr = ReadAllIdleInstalls(idles, hive, root, 0);

if (FAILED(hr)) {
idles.clear();
if (FAILED(hr)) {
idles.clear();
}
}
}
#endif
Expand Down Expand Up @@ -429,7 +469,7 @@ class DECLSPEC_UUID(CLSID_IDLE_COMMAND) IdleCommand

IFACEMETHODIMP GetState(IShellItemArray *psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE *pCmdState)
{
*pCmdState = idles.size() ? ECS_ENABLED : ECS_HIDDEN;
*pCmdState = idles.size() ? ECS_ENABLED : ECS_DISABLED;
return S_OK;
}

Expand Down