[EXPLORER] Fix crash on backspace while editing a label in the folder panel (#5059)

While editing a label, accelerator events should not be propagated.
This commit is contained in:
Atharva Kulkarni 2023-02-14 01:15:39 +05:30 committed by GitHub
parent e60c0f6970
commit a777cc2cc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -149,6 +149,7 @@ CExplorerBand::CExplorerBand()
, m_fVisible(FALSE) , m_fVisible(FALSE)
, m_bNavigating(FALSE) , m_bNavigating(FALSE)
, m_dwBandID(0) , m_dwBandID(0)
, m_isEditing(FALSE)
, m_pidlCurrent(NULL) , m_pidlCurrent(NULL)
{ {
} }
@ -1217,6 +1218,9 @@ HRESULT STDMETHODCALLTYPE CExplorerBand::HasFocusIO()
HRESULT STDMETHODCALLTYPE CExplorerBand::TranslateAcceleratorIO(LPMSG lpMsg) HRESULT STDMETHODCALLTYPE CExplorerBand::TranslateAcceleratorIO(LPMSG lpMsg)
{ {
if (m_isEditing)
return S_FALSE;
if (lpMsg->hwnd == m_hWnd) if (lpMsg->hwnd == m_hWnd)
{ {
TranslateMessage(lpMsg); TranslateMessage(lpMsg);
@ -1314,7 +1318,10 @@ HRESULT STDMETHODCALLTYPE CExplorerBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM
hr = pParent->GetAttributesOf(1, &pChild, &dwAttr); hr = pParent->GetAttributesOf(1, &pChild, &dwAttr);
if (SUCCEEDED(hr) && (dwAttr & SFGAO_CANRENAME) && theResult) if (SUCCEEDED(hr) && (dwAttr & SFGAO_CANRENAME) && theResult)
{
*theResult = 0; *theResult = 0;
m_isEditing = TRUE;
}
return S_OK; return S_OK;
} }
case TVN_ENDLABELEDITW: case TVN_ENDLABELEDITW:
@ -1323,6 +1330,7 @@ HRESULT STDMETHODCALLTYPE CExplorerBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM
NodeInfo *info = GetNodeInfo(dispInfo->item.hItem); NodeInfo *info = GetNodeInfo(dispInfo->item.hItem);
HRESULT hr; HRESULT hr;
m_isEditing = FALSE;
if (theResult) if (theResult)
*theResult = 0; *theResult = 0;
if (dispInfo->item.pszText) if (dispInfo->item.pszText)

View file

@ -60,6 +60,7 @@ private:
BOOL m_bNavigating; BOOL m_bNavigating;
BOOL m_bFocused; BOOL m_bFocused;
DWORD m_dwBandID; DWORD m_dwBandID;
BOOL m_isEditing;
HIMAGELIST m_hImageList; HIMAGELIST m_hImageList;
HTREEITEM m_hRoot; HTREEITEM m_hRoot;
HTREEITEM m_oldSelected; HTREEITEM m_oldSelected;