Fix crash in propgrid sample, see #18537
This commit is contained in:
parent
ab33227578
commit
ffac936882
@ -2985,21 +2985,23 @@ void FormMain::OnSetPropertyValue( wxCommandEvent& WXUNUSED(event) )
|
||||
void FormMain::OnInsertChoice( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
|
||||
|
||||
wxPGProperty* selected = pg->GetSelection();
|
||||
const wxPGChoices& choices = selected->GetChoices();
|
||||
|
||||
// Insert new choice to the center of list
|
||||
if (selected)
|
||||
{
|
||||
const wxPGChoices& choices = selected->GetChoices();
|
||||
|
||||
if ( choices.IsOk() )
|
||||
{
|
||||
int pos = choices.GetCount() / 2;
|
||||
selected->InsertChoice("New Choice", pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
::wxMessageBox("First select a property with some choices.");
|
||||
if ( choices.IsOk() )
|
||||
{
|
||||
// Insert new choice to the center of list
|
||||
|
||||
int pos = choices.GetCount() / 2;
|
||||
selected->InsertChoice("New Choice", pos);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wxMessageBox("First select a property with some choices.");
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@ -3007,21 +3009,23 @@ void FormMain::OnInsertChoice( wxCommandEvent& WXUNUSED(event) )
|
||||
void FormMain::OnDeleteChoice( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
|
||||
|
||||
wxPGProperty* selected = pg->GetSelection();
|
||||
const wxPGChoices& choices = selected->GetChoices();
|
||||
|
||||
// Deletes choice from the center of list
|
||||
if (selected)
|
||||
{
|
||||
const wxPGChoices& choices = selected->GetChoices();
|
||||
|
||||
if ( choices.IsOk() )
|
||||
{
|
||||
int pos = choices.GetCount() / 2;
|
||||
selected->DeleteChoice(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
::wxMessageBox("First select a property with some choices.");
|
||||
if ( choices.IsOk() )
|
||||
{
|
||||
// Deletes choice from the center of list
|
||||
|
||||
int pos = choices.GetCount() / 2;
|
||||
selected->DeleteChoice(pos);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wxMessageBox("First select a property with some choices.");
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user