1. corrected uninitialised variable (which led to crash) in wxListBox

2. corrected assert failures in wxChoiceDialog


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4198 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 1999-10-26 13:54:58 +00:00
parent 505928852c
commit eb553cb25b
4 changed files with 21 additions and 12 deletions

View File

@ -64,13 +64,10 @@ public:
long style = wxCHOICEDLG_STYLE, long style = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition); const wxPoint& pos = wxDefaultPosition);
void SetSelection(int sel) ; void SetSelection(int sel);
int GetSelection() const { return m_selection; } int GetSelection() const { return m_selection; }
wxString GetStringSelection() const { return m_stringSelection; } wxString GetStringSelection() const { return m_stringSelection; }
// get client data associated with selection
void *GetClientData() const { return m_clientData; }
// obsolete function (NB: no need to make it return wxChar, it's untyped) // obsolete function (NB: no need to make it return wxChar, it's untyped)
char *GetSelectionClientData() const { return (char *)m_clientData; } char *GetSelectionClientData() const { return (char *)m_clientData; }

View File

@ -233,8 +233,6 @@ bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent),
const wxPoint& WXUNUSED(pos) ) const wxPoint& WXUNUSED(pos) )
{ {
m_selection = 0; m_selection = 0;
m_clientData = NULL;
m_stringSelection = wxT("");
m_dialogStyle = style; m_dialogStyle = style;
@ -290,7 +288,8 @@ void wxSingleChoiceDialog::OnOK(wxCommandEvent& WXUNUSED(event))
{ {
m_selection = m_listbox->GetSelection(); m_selection = m_listbox->GetSelection();
m_stringSelection = m_listbox->GetStringSelection(); m_stringSelection = m_listbox->GetStringSelection();
m_clientData = m_listbox->GetClientData(m_selection); if ( m_listbox->HasClientUntypedData() )
SetClientData(m_listbox->GetClientData(m_selection));
EndModal(wxID_OK); EndModal(wxID_OK);
} }
@ -299,7 +298,8 @@ void wxSingleChoiceDialog::OnListBoxDClick(wxCommandEvent& WXUNUSED(event))
{ {
m_selection = m_listbox->GetSelection(); m_selection = m_listbox->GetSelection();
m_stringSelection = m_listbox->GetStringSelection(); m_stringSelection = m_listbox->GetStringSelection();
m_clientData = m_listbox->GetClientData(m_selection); if ( m_listbox->HasClientUntypedData() )
SetClientData(m_listbox->GetClientData(m_selection));
EndModal(wxID_OK); EndModal(wxID_OK);
} }

View File

@ -310,8 +310,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
gtk_widget_show( GTK_WIDGET(m_list) ); gtk_widget_show( GTK_WIDGET(m_list) );
wxSize newSize = size; wxSize newSize = size;
if (newSize.x == -1) newSize.x = 100; if (newSize.x == -1)
if (newSize.y == -1) newSize.y = 110; newSize.x = 100;
if (newSize.y == -1)
newSize.y = 110;
SetSize( newSize.x, newSize.y ); SetSize( newSize.x, newSize.y );
if ( style & wxLB_SORT ) if ( style & wxLB_SORT )
@ -319,6 +321,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
// this will change DoAppend() behaviour // this will change DoAppend() behaviour
m_strings = new wxSortedArrayString; m_strings = new wxSortedArrayString;
} }
else
{
m_strings = (wxSortedArrayString *)NULL;
}
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
{ {

View File

@ -310,8 +310,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
gtk_widget_show( GTK_WIDGET(m_list) ); gtk_widget_show( GTK_WIDGET(m_list) );
wxSize newSize = size; wxSize newSize = size;
if (newSize.x == -1) newSize.x = 100; if (newSize.x == -1)
if (newSize.y == -1) newSize.y = 110; newSize.x = 100;
if (newSize.y == -1)
newSize.y = 110;
SetSize( newSize.x, newSize.y ); SetSize( newSize.x, newSize.y );
if ( style & wxLB_SORT ) if ( style & wxLB_SORT )
@ -319,6 +321,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
// this will change DoAppend() behaviour // this will change DoAppend() behaviour
m_strings = new wxSortedArrayString; m_strings = new wxSortedArrayString;
} }
else
{
m_strings = (wxSortedArrayString *)NULL;
}
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
{ {