Only attempt to update the sort order if the control has a model attached.

This commit is contained in:
iwbnwif
2017-08-23 00:21:02 +01:00
parent 110505543f
commit 326b76e649

View File

@@ -133,9 +133,11 @@ public:
// TODO: Set the column's view position.
}
// Restore the sort key and order.
// Restore the sort key and order if there is a valid model and sort
// criteria.
wxString sortColumn;
if ( RestoreValue(wxPERSIST_DVLC_SORT_KEY, &sortColumn) &&
if ( control->GetModel() &&
RestoreValue(wxPERSIST_DVLC_SORT_KEY, &sortColumn) &&
sortColumn != "" )
{
bool sortAsc = true;
@@ -145,6 +147,8 @@ public:
{
RestoreValue(wxPERSIST_DVLC_SORT_ASC, &sortAsc);
column->SetSortOrder(sortAsc);
// Resort the control based on the new sort criteria.
control->GetModel()->Resort();
}
}