Don't allow using GetPath/GetFilename() with wxFD_MULTIPLE

GetPaths/GetFilenames() must be used instead when more than one file
could be selected: document this and assert if the wrong functions are
called.

Closes https://github.com/wxWidgets/wxWidgets/pull/1883
This commit is contained in:
Ian McInerney
2020-06-02 10:34:37 +01:00
committed by Vadim Zeitlin
parent 284cf9a872
commit 4ac648901d
6 changed files with 35 additions and 4 deletions

View File

@@ -104,10 +104,19 @@ public:
virtual void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; }
virtual wxString GetMessage() const { return m_message; }
virtual wxString GetPath() const { return m_path; }
virtual wxString GetPath() const
{
wxCHECK_MSG( !HasFlag(wxFD_MULTIPLE), wxString(), "When using wxFD_MULTIPLE, must call GetPaths() instead" );
return m_path;
}
virtual void GetPaths(wxArrayString& paths) const { paths.Empty(); paths.Add(m_path); }
virtual wxString GetDirectory() const { return m_dir; }
virtual wxString GetFilename() const { return m_fileName; }
virtual wxString GetFilename() const
{
wxCHECK_MSG( !HasFlag(wxFD_MULTIPLE), wxString(), "When using wxFD_MULTIPLE, must call GetFilenames() instead" );
return m_fileName;
}
virtual void GetFilenames(wxArrayString& files) const { files.Empty(); files.Add(m_fileName); }
virtual wxString GetWildcard() const { return m_wildCard; }
virtual int GetFilterIndex() const { return m_filterIndex; }