From 7a0f57ea29d6bd13e1196907d72d49e5a9b6bbbf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 18 Sep 2019 02:05:07 +0200 Subject: [PATCH] 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. --- samples/dialogs/dialogs.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 337fdba27d..d54faab308 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -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;