Fix assert in the generic file dialog in the dialogs sample

Cast the dialog pointer to wxFileDialogBase to avoid failures when using
wxGenericFileDialog, which inherits from wxFileDialogBase, but not from
wxFileDialog itself.

Closes #18506.
This commit is contained in:
Vadim Zeitlin
2019-09-18 02:05:07 +02:00
parent e26d90028b
commit 7a0f57ea29

View File

@@ -1502,7 +1502,10 @@ private:
void OnUpdateLabelUI(wxUpdateUIEvent& event)
{
wxFileDialog* const dialog = wxStaticCast(GetParent(), wxFileDialog);
// In this sample, the dialog may be either wxFileDialog itself, or
// wxGenericFileDialog, so we need to cast to the base class. In a
// typical application, we would cast to just wxFileDialog instead.
wxFileDialogBase* const dialog = wxStaticCast(GetParent(), wxFileDialogBase);
const wxString fn = dialog->GetCurrentlySelectedFilename();
wxString msg;