X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cff48ba847a27ba4fb3402f4542d40251c5a7a27..357f4c818d25cd63efc90363cc48d79c76f2faf1:/src/generic/listctrl.cpp diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 1a82b85138..5a3ef5ac90 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -5061,12 +5061,22 @@ bool wxGenericListCtrl::DoPopupMenu( wxMenu *menu, int x, int y ) void wxGenericListCtrl::DoClientToScreen( int *x, int *y ) const { - m_mainWin->DoClientToScreen(x, y); + // It's not clear whether this can be called before m_mainWin is created + // but it seems better to be on the safe side and check. + if ( m_mainWin ) + m_mainWin->DoClientToScreen(x, y); + else + wxControl::DoClientToScreen(x, y); } void wxGenericListCtrl::DoScreenToClient( int *x, int *y ) const { - m_mainWin->DoScreenToClient(x, y); + // At least in wxGTK/Univ build this method can be called before m_mainWin + // is created so avoid crashes in this case. + if ( m_mainWin ) + m_mainWin->DoScreenToClient(x, y); + else + wxControl::DoScreenToClient(x, y); } void wxGenericListCtrl::SetFocus()