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:
@@ -203,6 +203,8 @@ bool wxFilePickerCtrl::Create(wxWindow *parent,
|
|||||||
|
|
||||||
wxString wxFilePickerCtrl::GetTextCtrlValue() const
|
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
|
// filter it through wxFileName to remove any spurious path separator
|
||||||
return wxFileName(m_text->GetValue()).GetFullPath();
|
return wxFileName(m_text->GetValue()).GetFullPath();
|
||||||
}
|
}
|
||||||
@@ -241,6 +243,8 @@ bool wxDirPickerCtrl::Create(wxWindow *parent,
|
|||||||
|
|
||||||
wxString wxDirPickerCtrl::GetTextCtrlValue() const
|
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
|
// filter it through wxFileName to remove any spurious path separator
|
||||||
return wxFileName::DirName(m_text->GetValue()).GetPath();
|
return wxFileName::DirName(m_text->GetValue()).GetPath();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user