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();
|
DestroyTree();
|
||||||
m_selection.Clear();
|
m_selection.Clear();
|
||||||
|
|
||||||
|
if (GetModel())
|
||||||
|
{
|
||||||
SortPrepare();
|
SortPrepare();
|
||||||
BuildTree( GetModel() );
|
BuildTree( GetModel() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
GetOwner()->InvalidateColBestWidths();
|
GetOwner()->InvalidateColBestWidths();
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
@@ -4526,13 +4533,23 @@ bool wxDataViewCtrl::AssociateModel( wxDataViewModel *model )
|
|||||||
if (!wxDataViewCtrlBase::AssociateModel( model ))
|
if (!wxDataViewCtrlBase::AssociateModel( model ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (model)
|
||||||
|
{
|
||||||
m_notifier = new wxGenericDataViewModelNotifier( m_clientArea );
|
m_notifier = new wxGenericDataViewModelNotifier( m_clientArea );
|
||||||
|
|
||||||
model->AddNotifier( m_notifier );
|
model->AddNotifier( m_notifier );
|
||||||
|
}
|
||||||
|
else if (m_notifier)
|
||||||
|
{
|
||||||
|
m_notifier->Cleared();
|
||||||
|
m_notifier = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
m_clientArea->DestroyTree();
|
m_clientArea->DestroyTree();
|
||||||
|
|
||||||
|
if (model)
|
||||||
|
{
|
||||||
m_clientArea->BuildTree(model);
|
m_clientArea->BuildTree(model);
|
||||||
|
}
|
||||||
|
|
||||||
m_clientArea->UpdateDisplay();
|
m_clientArea->UpdateDisplay();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user