Don't crash in wx{File,Dir}PickerCtrl::GetTextCtrlValue()

If there is no text field, assert and return empty string instead of
just crashing.

Closes #14078.
This commit is contained in:
Vadim Zeitlin
2019-07-25 21:43:00 +02:00
parent f9e80841dd
commit aba9c119fa

View File

@@ -203,6 +203,8 @@ bool wxFilePickerCtrl::Create(wxWindow *parent,
wxString wxFilePickerCtrl::GetTextCtrlValue() const
{
wxCHECK_MSG( m_text, wxString(), "Can't be used if no text control" );
// filter it through wxFileName to remove any spurious path separator
return wxFileName(m_text->GetValue()).GetFullPath();
}
@@ -241,6 +243,8 @@ bool wxDirPickerCtrl::Create(wxWindow *parent,
wxString wxDirPickerCtrl::GetTextCtrlValue() const
{
wxCHECK_MSG( m_text, wxString(), "Can't be used if no text control" );
// filter it through wxFileName to remove any spurious path separator
return wxFileName::DirName(m_text->GetValue()).GetPath();
}