Merge branch 'qt_combobox_crash' of https://github.com/GeoTeric/wxWidgets

Fix crashes when using wxCB_READONLY in wxQt.

See https://github.com/wxWidgets/wxWidgets/pull/1221
This commit is contained in:
Vadim Zeitlin
2019-02-05 03:04:21 +01:00
2 changed files with 13 additions and 3 deletions

View File

@@ -87,6 +87,7 @@ protected:
private: private:
void SetActualValue(const wxString& value); void SetActualValue(const wxString& value);
bool IsReadOnly() const;
// From wxTextEntry: // From wxTextEntry:
virtual wxWindow *GetEditableWindow() wxOVERRIDE { return this; } virtual wxWindow *GetEditableWindow() wxOVERRIDE { return this; }

View File

@@ -171,7 +171,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
void wxComboBox::SetActualValue(const wxString &value) void wxComboBox::SetActualValue(const wxString &value)
{ {
if ( HasFlag(wxCB_READONLY) ) if ( IsReadOnly() )
{ {
SetStringSelection( value ); SetStringSelection( value );
} }
@@ -182,9 +182,16 @@ void wxComboBox::SetActualValue(const wxString &value)
} }
} }
bool wxComboBox::IsReadOnly() const
{
return HasFlag( wxCB_READONLY );
}
void wxComboBox::SetValue(const wxString& value) void wxComboBox::SetValue(const wxString& value)
{ {
SetActualValue( value ); SetActualValue( value );
if ( !IsReadOnly() )
SetInsertionPoint( 0 ); SetInsertionPoint( 0 );
} }
@@ -249,7 +256,9 @@ void wxComboBox::Dismiss()
void wxComboBox::Clear() void wxComboBox::Clear()
{ {
if ( !IsReadOnly() )
wxTextEntry::Clear(); wxTextEntry::Clear();
wxItemContainer::Clear(); wxItemContainer::Clear();
} }