From: Vadim Zeitlin Date: Thu, 21 Aug 2003 23:08:10 +0000 (+0000) Subject: ensure that GetItemRect() returns the real rect and not 0 even if it's called before... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1e54be64fd06fc0eecccbf75c514a76e2cf23f0c?ds=inline ensure that GetItemRect() returns the real rect and not 0 even if it's called before first OnIdle() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23084 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 21f74335b6..6674b681f6 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -3778,6 +3778,13 @@ void wxListMainWindow::GetItemRect( long index, wxRect &rect ) const wxCHECK_RET( index >= 0 && (size_t)index < GetItemCount(), _T("invalid index in GetItemRect") ); + // ensure that we're laid out, otherwise we could return nonsense + if ( m_dirty ) + { + wxConstCast(this, wxListMainWindow)-> + RecalculatePositions(TRUE /* no refresh */); + } + rect = GetLineRect((size_t)index); CalcScrolledPosition(rect.x, rect.y, &rect.x, &rect.y);