From: Vadim Zeitlin Date: Mon, 29 Oct 2012 18:30:14 +0000 (+0000) Subject: Compare file paths using wxFileName, not wxString, in the sample. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a7156681007c718be299389f68326b1c71486878 Compare file paths using wxFileName, not wxString, in the sample. Comparing paths using wxString is a bad idea as identical paths can be seen as mismatching because of case-only differences. Also, don't reset wxRadioBox selection from its selection handler, this doesn't work under e.g. wxGTK and is a bad example. Closes #14791. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72820 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/widgets/dirctrl.cpp b/samples/widgets/dirctrl.cpp index 21b0bbfe08..0698b926de 100644 --- a/samples/widgets/dirctrl.cpp +++ b/samples/widgets/dirctrl.cpp @@ -42,6 +42,7 @@ #include "wx/wupdlock.h" #include "wx/stdpaths.h" +#include "wx/filename.h" #include "widgets.h" @@ -349,10 +350,13 @@ void DirCtrlWidgetsPage::OnRadioBox(wxCommandEvent& WXUNUSED(event)) } m_dirCtrl->SetPath(path); - if(!m_dirCtrl->GetPath().IsSameAs(path)) + + // Notice that we must use wxFileName comparison instead of simple wxString + // comparison as the paths returned may differ by case only. + if ( wxFileName(m_dirCtrl->GetPath()) != path ) { - wxLogMessage(wxT("Selected standard path and path from control do not match!")); - m_radioStdPath->SetSelection(stdPathUnknown); + wxLogMessage("Failed to go to \"%s\", the current path is \"%s\".", + path, m_dirCtrl->GetPath()); } }