Don't crash in generic wxDataViewCtrl if it doesn't have any model.
A model may be dissociated from a still existing control, don't crash if it happens (notice that we still would crash in the native GTK version right now, so this still remains to be fixed there). See #14616. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72590 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2465,8 +2465,15 @@ bool wxDataViewMainWindow::Cleared()
|
||||
DestroyTree();
|
||||
m_selection.Clear();
|
||||
|
||||
SortPrepare();
|
||||
BuildTree( GetModel() );
|
||||
if (GetModel())
|
||||
{
|
||||
SortPrepare();
|
||||
BuildTree( GetModel() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_count = 0;
|
||||
}
|
||||
|
||||
GetOwner()->InvalidateColBestWidths();
|
||||
UpdateDisplay();
|
||||
@@ -4526,13 +4533,23 @@ bool wxDataViewCtrl::AssociateModel( wxDataViewModel *model )
|
||||
if (!wxDataViewCtrlBase::AssociateModel( model ))
|
||||
return false;
|
||||
|
||||
m_notifier = new wxGenericDataViewModelNotifier( m_clientArea );
|
||||
|
||||
model->AddNotifier( m_notifier );
|
||||
if (model)
|
||||
{
|
||||
m_notifier = new wxGenericDataViewModelNotifier( m_clientArea );
|
||||
model->AddNotifier( m_notifier );
|
||||
}
|
||||
else if (m_notifier)
|
||||
{
|
||||
m_notifier->Cleared();
|
||||
m_notifier = NULL;
|
||||
}
|
||||
|
||||
m_clientArea->DestroyTree();
|
||||
|
||||
m_clientArea->BuildTree(model);
|
||||
if (model)
|
||||
{
|
||||
m_clientArea->BuildTree(model);
|
||||
}
|
||||
|
||||
m_clientArea->UpdateDisplay();
|
||||
|
||||
|
Reference in New Issue
Block a user