mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 17:10:22 +00:00
[SHELL32] Check m_ListView on some methods (#5684)
- comdlg32:filedlg could encounter an assertion error in CWindow::SendMessage. - Assert the existence of the listview control m_ListView in the CDefView::LV_... function. - Actually check the existence of m_ListView outside the CDefView::LV_... function. ROSTESTS-388
This commit is contained in:
parent
bcd916bd4e
commit
5c7a5786fd
1 changed files with 52 additions and 6 deletions
|
@ -545,6 +545,9 @@ void CDefView::UpdateStatusbar()
|
||||||
WCHAR szPartText[MAX_PATH] = {0};
|
WCHAR szPartText[MAX_PATH] = {0};
|
||||||
UINT cSelectedItems;
|
UINT cSelectedItems;
|
||||||
|
|
||||||
|
if (!m_ListView)
|
||||||
|
return;
|
||||||
|
|
||||||
cSelectedItems = m_ListView.GetSelectedCount();
|
cSelectedItems = m_ListView.GetSelectedCount();
|
||||||
if (cSelectedItems)
|
if (cSelectedItems)
|
||||||
{
|
{
|
||||||
|
@ -884,6 +887,8 @@ PCUITEMID_CHILD CDefView::_PidlByItem(LVITEM& lvItem)
|
||||||
*/
|
*/
|
||||||
int CDefView::LV_FindItemByPidl(PCUITEMID_CHILD pidl)
|
int CDefView::LV_FindItemByPidl(PCUITEMID_CHILD pidl)
|
||||||
{
|
{
|
||||||
|
ASSERT(m_ListView);
|
||||||
|
|
||||||
int cItems = m_ListView.GetItemCount();
|
int cItems = m_ListView.GetItemCount();
|
||||||
|
|
||||||
for (int i = 0; i<cItems; i++)
|
for (int i = 0; i<cItems; i++)
|
||||||
|
@ -904,6 +909,8 @@ int CDefView::LV_AddItem(PCUITEMID_CHILD pidl)
|
||||||
|
|
||||||
TRACE("(%p)(pidl=%p)\n", this, pidl);
|
TRACE("(%p)(pidl=%p)\n", this, pidl);
|
||||||
|
|
||||||
|
ASSERT(m_ListView);
|
||||||
|
|
||||||
if (_DoFolderViewCB(SFVM_ADDINGOBJECT, 0, (LPARAM)pidl) == S_FALSE)
|
if (_DoFolderViewCB(SFVM_ADDINGOBJECT, 0, (LPARAM)pidl) == S_FALSE)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -927,7 +934,11 @@ BOOLEAN CDefView::LV_DeleteItem(PCUITEMID_CHILD pidl)
|
||||||
|
|
||||||
TRACE("(%p)(pidl=%p)\n", this, pidl);
|
TRACE("(%p)(pidl=%p)\n", this, pidl);
|
||||||
|
|
||||||
|
ASSERT(m_ListView);
|
||||||
|
|
||||||
nIndex = LV_FindItemByPidl(pidl);
|
nIndex = LV_FindItemByPidl(pidl);
|
||||||
|
if (nIndex < 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
return m_ListView.DeleteItem(nIndex);
|
return m_ListView.DeleteItem(nIndex);
|
||||||
}
|
}
|
||||||
|
@ -942,6 +953,8 @@ BOOLEAN CDefView::LV_RenameItem(PCUITEMID_CHILD pidlOld, PCUITEMID_CHILD pidlNew
|
||||||
|
|
||||||
TRACE("(%p)(pidlold=%p pidlnew=%p)\n", this, pidlOld, pidlNew);
|
TRACE("(%p)(pidlold=%p pidlnew=%p)\n", this, pidlOld, pidlNew);
|
||||||
|
|
||||||
|
ASSERT(m_ListView);
|
||||||
|
|
||||||
nItem = LV_FindItemByPidl(pidlOld);
|
nItem = LV_FindItemByPidl(pidlOld);
|
||||||
|
|
||||||
if ( -1 != nItem )
|
if ( -1 != nItem )
|
||||||
|
@ -980,6 +993,8 @@ BOOLEAN CDefView::LV_ProdItem(PCUITEMID_CHILD pidl)
|
||||||
|
|
||||||
TRACE("(%p)(pidl=%p)\n", this, pidl);
|
TRACE("(%p)(pidl=%p)\n", this, pidl);
|
||||||
|
|
||||||
|
ASSERT(m_ListView);
|
||||||
|
|
||||||
nItem = LV_FindItemByPidl(pidl);
|
nItem = LV_FindItemByPidl(pidl);
|
||||||
|
|
||||||
if (-1 != nItem)
|
if (-1 != nItem)
|
||||||
|
@ -1009,7 +1024,7 @@ INT CALLBACK CDefView::fill_list(LPVOID ptr, LPVOID arg)
|
||||||
CDefView *pThis = static_cast<CDefView *>(arg);
|
CDefView *pThis = static_cast<CDefView *>(arg);
|
||||||
|
|
||||||
/* in a commdlg This works as a filemask*/
|
/* in a commdlg This works as a filemask*/
|
||||||
if (pThis->IncludeObject(pidl) == S_OK)
|
if (pThis->IncludeObject(pidl) == S_OK && pThis->m_ListView)
|
||||||
pThis->LV_AddItem(pidl);
|
pThis->LV_AddItem(pidl);
|
||||||
|
|
||||||
SHFree(pidl);
|
SHFree(pidl);
|
||||||
|
@ -1482,6 +1497,8 @@ UINT CDefView::GetSelections()
|
||||||
|
|
||||||
TRACE("-- Items selected =%u\n", m_cidl);
|
TRACE("-- Items selected =%u\n", m_cidl);
|
||||||
|
|
||||||
|
ASSERT(m_ListView);
|
||||||
|
|
||||||
UINT i = 0;
|
UINT i = 0;
|
||||||
int lvIndex = -1;
|
int lvIndex = -1;
|
||||||
while ((lvIndex = m_ListView.GetNextItem(lvIndex, LVNI_SELECTED)) > -1)
|
while ((lvIndex = m_ListView.GetNextItem(lvIndex, LVNI_SELECTED)) > -1)
|
||||||
|
@ -1734,11 +1751,12 @@ LRESULT CDefView::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled
|
||||||
|
|
||||||
TRACE("%p width=%u height=%u\n", this, wWidth, wHeight);
|
TRACE("%p width=%u height=%u\n", this, wWidth, wHeight);
|
||||||
|
|
||||||
|
// WM_SIZE can come before WM_CREATE
|
||||||
|
if (!m_ListView)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* Resize the ListView to fit our window */
|
/* Resize the ListView to fit our window */
|
||||||
if (m_ListView)
|
::MoveWindow(m_ListView, 0, 0, wWidth, wHeight, TRUE);
|
||||||
{
|
|
||||||
::MoveWindow(m_ListView, 0, 0, wWidth, wHeight, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
_DoFolderViewCB(SFVM_SIZE, 0, 0);
|
_DoFolderViewCB(SFVM_SIZE, 0, 0);
|
||||||
|
|
||||||
|
@ -2313,6 +2331,10 @@ static BOOL ILIsParentOrSpecialParent(PCIDLIST_ABSOLUTE pidl1, PCIDLIST_ABSOLUTE
|
||||||
*/
|
*/
|
||||||
LRESULT CDefView::OnChangeNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
|
LRESULT CDefView::OnChangeNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
|
||||||
{
|
{
|
||||||
|
// The change notify can come before WM_CREATE.
|
||||||
|
if (!m_ListView)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
HANDLE hChange = (HANDLE)wParam;
|
HANDLE hChange = (HANDLE)wParam;
|
||||||
DWORD dwProcID = (DWORD)lParam;
|
DWORD dwProcID = (DWORD)lParam;
|
||||||
PIDLIST_ABSOLUTE *Pidls;
|
PIDLIST_ABSOLUTE *Pidls;
|
||||||
|
@ -2658,6 +2680,12 @@ HRESULT WINAPI CDefView::SelectItem(PCUITEMID_CHILD pidl, UINT uFlags)
|
||||||
|
|
||||||
TRACE("(%p)->(pidl=%p, 0x%08x) stub\n", this, pidl, uFlags);
|
TRACE("(%p)->(pidl=%p, 0x%08x) stub\n", this, pidl, uFlags);
|
||||||
|
|
||||||
|
if (!m_ListView)
|
||||||
|
{
|
||||||
|
ERR("!m_ListView\n");
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
i = LV_FindItemByPidl(pidl);
|
i = LV_FindItemByPidl(pidl);
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -2866,6 +2894,12 @@ HRESULT STDMETHODCALLTYPE CDefView::GetFocusedItem(int *piItem)
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CDefView::GetItemPosition(PCUITEMID_CHILD pidl, POINT *ppt)
|
HRESULT STDMETHODCALLTYPE CDefView::GetItemPosition(PCUITEMID_CHILD pidl, POINT *ppt)
|
||||||
{
|
{
|
||||||
|
if (!m_ListView)
|
||||||
|
{
|
||||||
|
ERR("!m_ListView\n");
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
int lvIndex = LV_FindItemByPidl(pidl);
|
int lvIndex = LV_FindItemByPidl(pidl);
|
||||||
if (lvIndex == -1 || ppt == NULL)
|
if (lvIndex == -1 || ppt == NULL)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
@ -2879,7 +2913,10 @@ HRESULT STDMETHODCALLTYPE CDefView::GetSpacing(POINT *ppt)
|
||||||
TRACE("(%p)->(%p)\n", this, ppt);
|
TRACE("(%p)->(%p)\n", this, ppt);
|
||||||
|
|
||||||
if (!m_ListView)
|
if (!m_ListView)
|
||||||
|
{
|
||||||
|
ERR("!m_ListView\n");
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (ppt)
|
if (ppt)
|
||||||
{
|
{
|
||||||
|
@ -2942,6 +2979,8 @@ HRESULT STDMETHODCALLTYPE CDefView::SelectItem(int iItem, DWORD dwFlags)
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CDefView::SelectAndPositionItems(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, POINT *apt, DWORD dwFlags)
|
HRESULT STDMETHODCALLTYPE CDefView::SelectAndPositionItems(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, POINT *apt, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
|
ASSERT(m_ListView);
|
||||||
|
|
||||||
/* Reset the selection */
|
/* Reset the selection */
|
||||||
m_ListView.SetItemState(-1, 0, LVIS_SELECTED);
|
m_ListView.SetItemState(-1, 0, LVIS_SELECTED);
|
||||||
|
|
||||||
|
@ -3099,6 +3138,11 @@ HRESULT STDMETHODCALLTYPE CDefView::AutoArrange()
|
||||||
HRESULT STDMETHODCALLTYPE CDefView::AddObject(PITEMID_CHILD pidl, UINT *item)
|
HRESULT STDMETHODCALLTYPE CDefView::AddObject(PITEMID_CHILD pidl, UINT *item)
|
||||||
{
|
{
|
||||||
TRACE("(%p)->(%p %p)\n", this, pidl, item);
|
TRACE("(%p)->(%p %p)\n", this, pidl, item);
|
||||||
|
if (!m_ListView)
|
||||||
|
{
|
||||||
|
ERR("!m_ListView\n");
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
*item = LV_AddItem(pidl);
|
*item = LV_AddItem(pidl);
|
||||||
return (int)*item >= 0 ? S_OK : E_OUTOFMEMORY;
|
return (int)*item >= 0 ? S_OK : E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
@ -3111,11 +3155,13 @@ HRESULT STDMETHODCALLTYPE CDefView::GetObject(PITEMID_CHILD *pidl, UINT item)
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CDefView::RemoveObject(PITEMID_CHILD pidl, UINT *item)
|
HRESULT STDMETHODCALLTYPE CDefView::RemoveObject(PITEMID_CHILD pidl, UINT *item)
|
||||||
{
|
{
|
||||||
|
|
||||||
TRACE("(%p)->(%p %p)\n", this, pidl, item);
|
TRACE("(%p)->(%p %p)\n", this, pidl, item);
|
||||||
|
|
||||||
if (!m_ListView)
|
if (!m_ListView)
|
||||||
|
{
|
||||||
|
ERR("!m_ListView\n");
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
if (pidl)
|
if (pidl)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue