]> git.saurik.com Git - wxWidgets.git/commitdiff
Add wxDir::Close().
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 24 Jul 2012 20:45:30 +0000 (20:45 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 24 Jul 2012 20:45:30 +0000 (20:45 +0000)
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

docs/changes.txt
include/wx/dir.h
interface/wx/dir.h
src/msw/dir.cpp
src/unix/dir.cpp

index 9fda726f5e2b603072174fb8d97b30548d7836fd..5e1d4b56bc4cf1a251ef180329e8e79906cd7124 100644 (file)
@@ -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).
index 0781b13c13d470d8879f364a883d75d492f1bd73..83dab66454b83c7a296bdcc1b237d76c1b893e8b 100644 (file)
@@ -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;
 
index 3eafb364574ff80382a7007b7a2dfb2e0ca360e3..f4b25eb29f2a62f841216dedb02480599ea0f87e 100644 (file)
@@ -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.
     */
index bb059dc99292e3d4546b9a98a23ad07f9bace458..2eea8fe7ffc04f4444aa45f630d2d8f98ef89f0e 100644 (file)
@@ -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;
+    }
 }
 
 // ----------------------------------------------------------------------------
index b67c9dd9c601f21da6d0d717c522cb178b345b2f..f274a208d13cab0f64722ab5de49d3ec2cc0dd62 100644 (file)
@@ -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;
+    }
 }
 
 // ----------------------------------------------------------------------------