Fix for assert after left click on tree in generic dir dialog in native MSW build. Source cleaning and readability fixes.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30742 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2004-11-23 19:58:47 +00:00
parent f05ebffd6b
commit 44d60c0b26
3 changed files with 39 additions and 24 deletions

View File

@@ -383,7 +383,7 @@ void wxDirItemData::SetNewDirName(const wxString& path)
bool wxDirItemData::HasSubDirs() const
{
if (m_path.IsEmpty())
if (m_path.empty())
return false;
wxDir dir;
@@ -398,7 +398,7 @@ bool wxDirItemData::HasSubDirs() const
bool wxDirItemData::HasFiles(const wxString& WXUNUSED(spec)) const
{
if (m_path.IsEmpty())
if (m_path.empty())
return false;
wxDir dir;
@@ -522,7 +522,7 @@ bool wxGenericDirCtrl::Create(wxWindow *parent,
m_treeCtrl = CreateTreeCtrl(this, wxID_TREECTRL,
wxPoint(0,0), GetClientSize(), treeStyle);
if (!filter.IsEmpty() && (style & wxDIRCTRL_SHOW_FILTERS))
if (!filter.empty() && (style & wxDIRCTRL_SHOW_FILTERS))
m_filterListCtrl = new wxDirFilterListCtrl(this, wxID_FILTERLISTCTRL, wxDefaultPosition, wxDefaultSize, filterStyle);
m_defaultPath = dir;
@@ -642,7 +642,7 @@ void wxGenericDirCtrl::OnBeginEditItem(wxTreeEvent &event)
void wxGenericDirCtrl::OnEndEditItem(wxTreeEvent &event)
{
if ((event.GetLabel().IsEmpty()) ||
if ((event.GetLabel().empty()) ||
(event.GetLabel() == _(".")) ||
(event.GetLabel() == _("..")) ||
(event.GetLabel().Find(wxT('/')) != wxNOT_FOUND) ||
@@ -905,7 +905,7 @@ wxTreeItemId wxGenericDirCtrl::FindChild(wxTreeItemId parentId, const wxString&
{
wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(childId);
if (data && !data->m_path.IsEmpty())
if (data && !data->m_path.empty())
{
wxString childPath(data->m_path);
if (!wxEndsWithPathSeparator(childPath))
@@ -1625,13 +1625,13 @@ int wxFileIconsTable::GetIconID(const wxString& extension, const wxString& mime)
Create();
#if wxUSE_MIMETYPE
if (!extension.IsEmpty())
if (!extension.empty())
{
wxFileIconEntry *entry = (wxFileIconEntry*) m_HashTable->Get(extension);
if (entry) return (entry -> id);
}
wxFileType *ft = (mime.IsEmpty()) ?
wxFileType *ft = (mime.empty()) ?
wxTheMimeTypesManager -> GetFileTypeFromExtension(extension) :
wxTheMimeTypesManager -> GetFileTypeFromMimeType(mime);

View File

@@ -278,7 +278,13 @@ void wxGenericDirDialog::OnTreeSelected( wxTreeEvent &event )
if (!m_dirCtrl)
return;
wxDirItemData *data = (wxDirItemData*)m_dirCtrl->GetTreeCtrl()->GetItemData(event.GetItem());
wxTreeItemId item = event.GetItem();
wxDirItemData *data = NULL;
if(item.IsOk())
data = (wxDirItemData*)m_dirCtrl->GetTreeCtrl()->GetItemData(item);
if (data)
m_input->SetValue( data->m_path );
};

View File

@@ -1497,8 +1497,14 @@ wxTreeItemId wxTreeCtrl::GetFirstChild(const wxTreeItemId& item,
wxTreeItemId wxTreeCtrl::GetNextChild(const wxTreeItemId& WXUNUSED(item),
wxTreeItemIdValue& cookie) const
{
wxTreeItemId item(TreeView_GetNextSibling(GetHwnd(),
HITEM(wxTreeItemId(cookie))));
wxTreeItemId fromCookie(cookie);
HTREEITEM hitem = HITEM(fromCookie);
hitem = TreeView_GetNextSibling(GetHwnd(), hitem);
wxTreeItemId item(hitem);
cookie = item.m_pItem;
return item;
@@ -1519,11 +1525,14 @@ wxTreeItemId wxTreeCtrl::GetFirstChild(const wxTreeItemId& item,
wxTreeItemId wxTreeCtrl::GetNextChild(const wxTreeItemId& WXUNUSED(item),
long& cookie) const
{
wxTreeItemId item(TreeView_GetNextSibling
(
GetHwnd(),
HITEM(wxTreeItemId((void *)cookie)
)));
wxTreeItemId fromCookie((void *)cookie);
HTREEITEM hitem = HITEM(fromCookie);
hitem = TreeView_GetNextSibling(GetHwnd(), hitem);
wxTreeItemId item(hitem);
cookie = (long)item.m_pItem;
return item;
@@ -1646,7 +1655,7 @@ wxTreeItemId wxTreeCtrl::DoInsertItem(const wxTreeItemId& parent,
}
UINT mask = 0;
if ( !text.IsEmpty() )
if ( !text.empty() )
{
mask |= TVIF_TEXT;
tvIns.item.pszText = (wxChar *)text.c_str(); // cast is ok