From: Vadim Zeitlin Date: Wed, 23 Nov 2011 23:58:54 +0000 (+0000) Subject: Fix crash in wxTreeListCtrl::GetItemText() if text was never set. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/35ee173d0faded507ac7918e9da80c21ec859aef Fix crash in wxTreeListCtrl::GetItemText() if text was never set. Asking for the text of an item is not an error even if it was never set for any column but the first one so just return an empty string in this case instead of crashing. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69805 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/treelist.cpp b/src/generic/treelist.cpp index f7aca4aabb..18cb193d18 100644 --- a/src/generic/treelist.cpp +++ b/src/generic/treelist.cpp @@ -758,7 +758,12 @@ const wxString& wxTreeListModel::GetItemText(Node* item, unsigned col) const // empty string we can return reference to. wxCHECK_MSG( item, m_root->m_text, "Invalid item" ); - return col == 0 ? item->m_text : item->GetColumnText(col); + // Notice that asking for the text of a column of an item that doesn't have + // any column texts is not an error so we simply return an empty string in + // this case. + return col == 0 ? item->m_text + : item->HasColumnsTexts() ? item->GetColumnText(col) + : m_root->m_text; } void wxTreeListModel::SetItemText(Node* item, unsigned col, const wxString& text)