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:
committed by
Vadim Zeitlin
parent
284cf9a872
commit
4ac648901d
@@ -99,6 +99,9 @@ Changes in behaviour not resulting in compilation errors
|
||||
- wxSizer::RecalcSizes() shouldn't be called directly (note that it was never
|
||||
supposed to be called, only implemented), call Layout() instead.
|
||||
|
||||
- wxFileDialog::GetPath() and wxFileDialog::GetFilename() now assert and return
|
||||
an empty string if called on dialogs with the wxFD_MULTIPLE style.
|
||||
|
||||
|
||||
Changes in behaviour which may result in build errors
|
||||
-----------------------------------------------------
|
||||
|
@@ -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; }
|
||||
|
@@ -73,13 +73,19 @@ public:
|
||||
{ m_filectrl->SetWildcard(wildCard); }
|
||||
|
||||
virtual wxString GetPath() const wxOVERRIDE
|
||||
{ return m_filectrl->GetPath(); }
|
||||
{
|
||||
wxCHECK_MSG( !HasFlag(wxFD_MULTIPLE), wxString(), "When using wxFD_MULTIPLE, must call GetPaths() instead" );
|
||||
return m_filectrl->GetPath();
|
||||
}
|
||||
virtual void GetPaths(wxArrayString& paths) const wxOVERRIDE
|
||||
{ m_filectrl->GetPaths(paths); }
|
||||
virtual wxString GetDirectory() const wxOVERRIDE
|
||||
{ return m_filectrl->GetDirectory(); }
|
||||
virtual wxString GetFilename() const wxOVERRIDE
|
||||
{ return m_filectrl->GetFilename(); }
|
||||
{
|
||||
wxCHECK_MSG( !HasFlag(wxFD_MULTIPLE), wxString(), "When using wxFD_MULTIPLE, must call GetFilenames() instead" );
|
||||
return m_filectrl->GetFilename();
|
||||
}
|
||||
virtual void GetFilenames(wxArrayString& files) const wxOVERRIDE
|
||||
{ m_filectrl->GetFilenames(files); }
|
||||
virtual wxString GetWildcard() const wxOVERRIDE
|
||||
|
@@ -264,6 +264,9 @@ public:
|
||||
|
||||
/**
|
||||
Returns the default filename.
|
||||
|
||||
@note This function can't be used with dialogs which have the @c wxFD_MULTIPLE style,
|
||||
use GetFilenames() instead.
|
||||
*/
|
||||
virtual wxString GetFilename() const;
|
||||
|
||||
@@ -298,6 +301,9 @@ public:
|
||||
|
||||
/**
|
||||
Returns the full path (directory and filename) of the selected file.
|
||||
|
||||
@note This function can't be used with dialogs which have the @c wxFD_MULTIPLE style,
|
||||
use GetPaths() instead.
|
||||
*/
|
||||
virtual wxString GetPath() const;
|
||||
|
||||
|
@@ -396,6 +396,7 @@ void wxFileDialog::OnSize(wxSizeEvent&)
|
||||
|
||||
wxString wxFileDialog::GetPath() const
|
||||
{
|
||||
wxCHECK_MSG( !HasFlag(wxFD_MULTIPLE), wxString(), "When using wxFD_MULTIPLE, must call GetPaths() instead" );
|
||||
return m_fc.GetPath();
|
||||
}
|
||||
|
||||
@@ -463,6 +464,8 @@ void wxFileDialog::SetFilename(const wxString& name)
|
||||
|
||||
wxString wxFileDialog::GetFilename() const
|
||||
{
|
||||
wxCHECK_MSG( !HasFlag(wxFD_MULTIPLE), wxString(), "When using wxFD_MULTIPLE, must call GetFilenames() instead" );
|
||||
|
||||
wxString currentFilename( m_fc.GetFilename() );
|
||||
if (currentFilename.empty())
|
||||
{
|
||||
|
@@ -103,6 +103,8 @@ bool wxFileDialog::Create(wxWindow *parent,
|
||||
|
||||
wxString wxFileDialog::GetPath() const
|
||||
{
|
||||
wxCHECK_MSG( !HasFlag(wxFD_MULTIPLE), wxString(), "When using wxFD_MULTIPLE, must call GetPaths() instead" );
|
||||
|
||||
wxArrayString paths;
|
||||
GetPaths(paths);
|
||||
if (paths.empty())
|
||||
@@ -120,6 +122,8 @@ void wxFileDialog::GetPaths(wxArrayString& paths) const
|
||||
|
||||
wxString wxFileDialog::GetFilename() const
|
||||
{
|
||||
wxCHECK_MSG( !HasFlag(wxFD_MULTIPLE), wxString(), "When using wxFD_MULTIPLE, must call GetFilenames() instead" );
|
||||
|
||||
wxArrayString filenames;
|
||||
GetFilenames(filenames);
|
||||
if ( filenames.empty() )
|
||||
|
Reference in New Issue
Block a user