From cd6e1c73c040d73308b3aeb7b06b33614d40ecf4 Mon Sep 17 00:00:00 2001 From: Kyle Katarn Date: Thu, 30 Apr 2020 23:03:10 +0200 Subject: [PATCH] [SHELL32] Fix "Open With..." spamming registry MRU keys. (#2685) CORE-16981 The problem: ============ - When opening "Open With..." dialog for a given file format, multiple MRU items are appended to registry : 2 items written, even if dialog is closed "cancel". - Expected behavior : 1 MRU item if execute is selected and 0 MRU if cancel is selected. Fix: ==== - MRU item to be added when "Execute" is selected only. - Once added, set the presence flag to avoid multiple MRU items being added later. --- dll/win32/shell32/COpenWithMenu.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dll/win32/shell32/COpenWithMenu.cpp b/dll/win32/shell32/COpenWithMenu.cpp index e9dd8018e35..2ad593bc559 100644 --- a/dll/win32/shell32/COpenWithMenu.cpp +++ b/dll/win32/shell32/COpenWithMenu.cpp @@ -534,8 +534,6 @@ VOID COpenWithList::LoadFromProgIdKey(HKEY hKey, LPCWSTR pwszExt) { StringCbCopyW(pApp->wszCmd, sizeof(pApp->wszCmd), wszCmd); SetRecommended(pApp); - if (!pApp->bMRUList) - AddAppToMRUList(pApp, pwszExt); } } } @@ -653,6 +651,9 @@ BOOL COpenWithList::AddAppToMRUList(SApp *pApp, LPCWSTR pwszFilename) /* Insert the entry */ AddMRUStringW(hList, pApp->wszFilename); + /* Set MRU presence */ + pApp->bMRUList = TRUE; + /* Close MRU list */ FreeMRUList(hList); }