diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 4a83697fd7..39d30b7614 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -825,7 +825,20 @@ wxGenericTreeCtrl::~wxGenericTreeCtrl() size_t wxGenericTreeCtrl::GetCount() const { - return m_anchor == NULL ? 0u : m_anchor->GetChildrenCount(); + if ( !m_anchor ) + { + // the tree is empty + return 0; + } + + size_t count = m_anchor->GetChildrenCount(); + if ( !HasFlag(wxTR_HIDE_ROOT) ) + { + // take the root itself into account + count++; + } + + return count; } void wxGenericTreeCtrl::SetIndent(unsigned int indent)