ecere/gui/Window: Prevent uninitialized values if base Window methods not overridden...
[sdk] / extras / FileSystemIterator.ec
index 60bb9b0..ba65bb8 100644 (file)
@@ -26,17 +26,13 @@ public:
    {
       StackFrame frame;
 
-      if(OnInit(startPath))
-      {
-         frame = stack.firstIterator.data;
-      }
-      else
-      {
-         frame = StackFrame { };
-         stack.Add(frame);
-         frame.path = CopyString(startPath);
-         frame.listing = FileListing { startPath, extensions = extensions };  // there should be a sorted = true/false
-      }
+      if(!OnInit(startPath))
+         return;
+
+      frame = StackFrame { };
+      stack.Add(frame);
+      frame.path = CopyString(startPath);
+      frame.listing = FileListing { startPath, extensions = extensions };  // there should be a sorted = true/false
 
       if(iterateStartPath)
       {
@@ -54,13 +50,11 @@ public:
       {
          if(frame.listing.Find())
          {
-            const char * name = frame.listing.name;
-            bool isDirectory = frame.listing.stats.attribs.isDirectory;
             bool peek = frame.listing.stats.attribs.isDirectory && OnFolder(frame.listing.path);
             if(!frame.listing.stats.attribs.isDirectory)
             {
                const char * path = frame.listing.path;
-               OnFile(frame.listing.path);
+               OnFile(path);
             }
             else if(peek)
             {
@@ -76,6 +70,7 @@ public:
             StackFrame parentFrame = stack.count > 1 ? stack[stack.count - 2] : null;
             OutFolder(parentFrame ? parentFrame.listing.path : startPath, !parentFrame);
             stack.lastIterator.Remove();
+            delete frame;
             if(stack.count)
                frame = stack.lastIterator.data;
             else
@@ -92,7 +87,7 @@ public:
 
    virtual bool OnInit(const char * startPath)
    {
-      return false;
+      return true;
    }
 
    virtual bool OnFile(const char * filePath)
@@ -114,7 +109,7 @@ public:
    {
    }
 }
-
+/*
 static class IteratorThread : Thread
 {
    void Temp()
@@ -122,7 +117,7 @@ static class IteratorThread : Thread
       //listing = FileListing { dir, extensions = filter.extensions };  // there should be a sorted = true/false
    }
 }
-
+*/
 public class StackFrame
 {
    int tag;