From 74bde8745fdb770a811fa6157d16c4d0ad413d04 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 28 Feb 2012 02:05:01 +0000 Subject: [PATCH] Fix setting default file name in wxGenericFileDirButton in wxGTK. Set the default directory first, if it's specified, and the file name later to ensure that it's interpreted relatively to this directory. Otherwise we could have a mismatch between the directory shown in the dialog and its initial path. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70732 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/filepickerg.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/generic/filepickerg.cpp b/src/generic/filepickerg.cpp index edfcfc5fea..3d5b975a9a 100644 --- a/src/generic/filepickerg.cpp +++ b/src/generic/filepickerg.cpp @@ -139,14 +139,19 @@ wxDialog *wxGenericFileButton::CreateDialog() GetDialogStyle() ); - // this sets both the default folder and the default file of the dialog - dialog->SetPath(m_path); - // If there is no default file or if it doesn't have any path, use the // explicitly set initial directory. + // + // Notice that it is important to call this before SetPath() below as if we + // do have m_initialDir and no directory in m_path, we need to interpret + // the path as being relative with respect to m_initialDir. if ( !m_initialDir.empty() ) DoSetInitialDirectory(dialog, m_initialDir); + // This sets both the default file name and the default directory of the + // dialog if m_path contains directory part. + dialog->SetPath(m_path); + return dialog; } -- 2.50.0