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) )
|
void FormMain::OnInsertChoice( wxCommandEvent& WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
|
wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
|
||||||
|
|
||||||
wxPGProperty* selected = pg->GetSelection();
|
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() )
|
if ( choices.IsOk() )
|
||||||
{
|
{
|
||||||
int pos = choices.GetCount() / 2;
|
// Insert new choice to the center of list
|
||||||
selected->InsertChoice("New Choice", pos);
|
|
||||||
}
|
int pos = choices.GetCount() / 2;
|
||||||
else
|
selected->InsertChoice("New Choice", pos);
|
||||||
{
|
return;
|
||||||
::wxMessageBox("First select a property with some choices.");
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxMessageBox("First select a property with some choices.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@ -3007,21 +3009,23 @@ void FormMain::OnInsertChoice( wxCommandEvent& WXUNUSED(event) )
|
|||||||
void FormMain::OnDeleteChoice( wxCommandEvent& WXUNUSED(event) )
|
void FormMain::OnDeleteChoice( wxCommandEvent& WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
|
wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
|
||||||
|
|
||||||
wxPGProperty* selected = pg->GetSelection();
|
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() )
|
if ( choices.IsOk() )
|
||||||
{
|
{
|
||||||
int pos = choices.GetCount() / 2;
|
// Deletes choice from the center of list
|
||||||
selected->DeleteChoice(pos);
|
|
||||||
}
|
int pos = choices.GetCount() / 2;
|
||||||
else
|
selected->DeleteChoice(pos);
|
||||||
{
|
return;
|
||||||
::wxMessageBox("First select a property with some choices.");
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxMessageBox("First select a property with some choices.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user