[BROWSEUI] Don't remember invoked non-folders in addressbar (#7954)

CORE-20091
This commit is contained in:
Whindmar Saksit
2025-05-09 16:19:49 +02:00
committed by GitHub
parent e0ef51b11e
commit afe29ee7fa
+19 -22
View File
@@ -250,6 +250,7 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::ShowFileNotFoundError(HRESULT hRet)
HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
{
BOOL bParsedForExec = FALSE;
HRESULT hr;
/*
@@ -270,6 +271,7 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
if (!m_pidlLastParsed)
return E_FAIL;
bParsedForExec = TRUE;
}
/*
@@ -277,7 +279,7 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
*/
CComPtr<IShellBrowser> pisb;
hr = IUnknown_QueryService(fSite, SID_SShellBrowser, IID_PPV_ARG(IShellBrowser, &pisb));
if (FAILED(hr))
if (FAILED_UNEXPECTEDLY(hr))
return hr;
/*
@@ -285,19 +287,15 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
*/
PIDLIST_ABSOLUTE pidl;
hr = GetAbsolutePidl(&pidl);
if (FAILED(hr))
if (FAILED_UNEXPECTEDLY(hr))
{
m_pidlLastParsed.Free();
return hr;
}
CComPtr<IShellFolder> psf;
hr = SHGetDesktopFolder(&psf);
if (FAILED(hr))
return hr;
hr = psf->CompareIDs(0, pidl, m_pidlLastParsed);
SHFree(pidl);
if (hr == S_OK)
BOOL bEqual = ILIsEqual(pidl, m_pidlLastParsed);
ILFree(pidl);
if (bEqual)
{
m_pidlLastParsed.Free();
return S_OK;
@@ -311,23 +309,22 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
return hr;
/*
* Browsing to the pidl failed so it's not a folder. So invoke its defaule command.
* Browsing to the pidl failed so it's not a folder. So invoke its default command.
*/
HWND topLevelWindow;
hr = IUnknown_GetWindow(pisb, &topLevelWindow);
if (FAILED(hr))
return hr;
HWND hWnd;
if (FAILED(IUnknown_GetWindow(pisb, &hWnd)))
hWnd = NULL;
LPCITEMIDLIST pidlChild;
CComPtr<IShellFolder> sf;
hr = SHBindToParent(m_pidlLastParsed, IID_PPV_ARG(IShellFolder, &sf), &pidlChild);
if (FAILED(hr))
return hr;
if (SUCCEEDED(hr))
hr = SHInvokeDefaultCommand(hWnd, sf, pidlChild);
hr = SHInvokeDefaultCommand(topLevelWindow, sf, pidlChild);
if (FAILED(hr))
return hr;
if (bParsedForExec)
m_pidlLastParsed.Free(); // Throw away the non-folder item we just parsed
RefreshAddress(); // Set the address back to a valid folder
return hr;
}