Jelajahi Sumber

Memory leak

Source commit: 41d63c12b31001ccfdb599833ace27cbfb18dcf2
Martin Prikryl 3 tahun lalu
induk
melakukan
ac049d1330
2 mengubah file dengan 18 tambahan dan 0 penghapusan
  1. 15 0
      source/core/Terminal.cpp
  2. 3 0
      source/core/Terminal.h

+ 15 - 0
source/core/Terminal.cpp

@@ -611,6 +611,19 @@ TCollectedFileList::TCollectedFileList()
 {
 }
 //---------------------------------------------------------------------------
+__fastcall TCollectedFileList::~TCollectedFileList()
+{
+  for (size_t Index = 0; Index < FList.size(); Index++)
+  {
+    Deleting(Index);
+  }
+}
+//---------------------------------------------------------------------------
+void TCollectedFileList::Deleting(int Index)
+{
+  delete FList[Index].Object;
+}
+//---------------------------------------------------------------------------
 int TCollectedFileList::Add(const UnicodeString & FileName, TObject * Object, bool Dir)
 {
   TFileData Data;
@@ -630,6 +643,7 @@ void TCollectedFileList::DidNotRecurse(int Index)
 //---------------------------------------------------------------------------
 void TCollectedFileList::Delete(int Index)
 {
+  Deleting(Index);
   FList.erase(FList.begin() + Index);
 }
 //---------------------------------------------------------------------------
@@ -7517,6 +7531,7 @@ bool __fastcall TTerminal::CopyToLocal(
       }
       OperationStop(OperationProgress);
     }
+    Files.reset(NULL);
   }
   __finally
   {

+ 3 - 0
source/core/Terminal.h

@@ -823,6 +823,7 @@ class TCollectedFileList : public TObject
 {
 public:
   TCollectedFileList();
+  virtual __fastcall ~TCollectedFileList();
   int Add(const UnicodeString & FileName, TObject * Object, bool Dir);
   void DidNotRecurse(int Index);
   void Delete(int Index);
@@ -836,6 +837,8 @@ public:
   void SetState(int Index, int State);
 
 private:
+  void Deleting(int Index);
+
   struct TFileData
   {
     UnicodeString FileName;