From 76ae7f748bac3c3821a5c419db2f31601ed73fa9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 23 Aug 2008 17:49:04 +0000 Subject: [PATCH] handle FNERR_INVALIDFILENAME which happens if an invalid file name is passed to wxFileDialog (#9688) [backport from trunk] git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@55207 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 3 ++- src/msw/filedlg.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 23e8f5977a..ce842d7764 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -133,12 +133,13 @@ wxMSW: wxWidgets 2.8.9 or later. - Fix keyboard support in wxSpinCtrl broken in 2.8.8. - Compile fix for WinCE in window.cpp (no VkKeyScan in Windows CE). -- Fix quoting of arguments passed to wxExecute(char **) (Brian Ravnsgaard Riis). - Support disabling items before adding them to the menu (Christian Walther). - Allow to call SetFont(wxNullFont) to reset the font to default. - Implement UUID::operator==() and !=() (SQLAware Corporation). - Fixed long standing (introduced in 2.6.3) bug which resulted in always creating a DIB and not DDB in wxBitmap(const wxImage&) ctor. +- Fix the bug with wxFileDialog not being shown at all if the default file name + was invalid. wxGTK: diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index ef9fd75fd8..c5725389f0 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -438,6 +438,13 @@ int wxFileDialog::ShowModal() DWORD errCode; bool success = DoShowCommFileDialog(&of, m_windowStyle, &errCode); + if ( !success && errCode == FNERR_INVALIDFILENAME && of.lpstrFile[0] ) + { + // this can happen if the default file name is invalid, try without it now + of.lpstrFile[0] = _T('\0'); + success = DoShowCommFileDialog(&of, m_windowStyle, &errCode); + } + #ifdef wxTRY_SMALLER_OPENFILENAME // the system might be too old to support the new version file dialog // boxes, try with the old size