From: Vadim Zeitlin Date: Tue, 24 Jul 2012 20:45:30 +0000 (+0000) Subject: Add wxDir::Close(). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6619c4af1b03055fc130d72077186867fbdd7340?ds=inline Add wxDir::Close(). This is trivial to have and can sometimes be useful and also is symmetric to Open(). Closes #14493. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72204 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/changes.txt b/docs/changes.txt index 9fda726f5e..5e1d4b56bc 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -527,6 +527,10 @@ Major new features in this release 2.9.5: (released ????-??-??) ---------------------------- +All: + +- Add wxDir::Close() method (Silverstorm82). + All (GUI): - Add possibility to hide and show again wxRibbonBar pages (wxBen). diff --git a/include/wx/dir.h b/include/wx/dir.h index 0781b13c13..83dab66454 100644 --- a/include/wx/dir.h +++ b/include/wx/dir.h @@ -94,12 +94,15 @@ public: // opens the directory for enumeration, use IsOpened() to test success wxDir(const wxString& dir); - // dtor cleans up the associated resources - ~wxDir(); + // dtor calls Close() automatically + ~wxDir() { Close(); } // open the directory for enumerating bool Open(const wxString& dir); + // close the directory, Open() can be called again later + void Close(); + // returns true if the directory was successfully opened bool IsOpened() const; diff --git a/interface/wx/dir.h b/interface/wx/dir.h index 3eafb36457..f4b25eb29f 100644 --- a/interface/wx/dir.h +++ b/interface/wx/dir.h @@ -160,11 +160,23 @@ public: wxDir(const wxString& dir); /** - Destructor cleans up the associated resources. It is not virtual and so - this class is not meant to be used polymorphically. + Destructor cleans up the associated resources by calling Close(). + + It is not virtual and so this class is not meant to be used + polymorphically. */ ~wxDir(); + /** + Close the directory. + + The object can't be used after closing it, but Open() may be called + again to reopen it later. + + @since 2.9.5 + */ + void Close(); + /** Test for existence of a directory with the given name. */ diff --git a/src/msw/dir.cpp b/src/msw/dir.cpp index bb059dc992..2eea8fe7ff 100644 --- a/src/msw/dir.cpp +++ b/src/msw/dir.cpp @@ -343,9 +343,13 @@ wxString wxDir::GetName() const return name; } -wxDir::~wxDir() +void wxDir::Close() { - delete M_DIR; + if ( m_data ) + { + delete m_data; + m_data = NULL; + } } // ---------------------------------------------------------------------------- diff --git a/src/unix/dir.cpp b/src/unix/dir.cpp index b67c9dd9c6..f274a208d1 100644 --- a/src/unix/dir.cpp +++ b/src/unix/dir.cpp @@ -248,9 +248,13 @@ wxString wxDir::GetName() const return name; } -wxDir::~wxDir() +void wxDir::Close() { - delete M_DIR; + if ( m_data ) + { + delete m_data; + m_data = NULL; + } } // ----------------------------------------------------------------------------