Browse Source

Deleting installer extension files when Preferences dialog is closed

Source commit: 73d0a9957d94f95c7af57ff696120de794bd0f82
Martin Prikryl 9 years ago
parent
commit
27119f3a11
2 changed files with 10 additions and 0 deletions
  1. 9 0
      source/forms/Preferences.cpp
  2. 1 0
      source/forms/Preferences.h

+ 9 - 0
source/forms/Preferences.cpp

@@ -75,6 +75,7 @@ __fastcall TPreferencesDialog::TPreferencesDialog(
   FEditorList = new TEditorList();
   FAutomaticUpdatesPossible = IsInstalled();
   FCustomCommandsHintItem = NULL;
+  FAddedExtensions.reset(new TStringList());
   UseSystemSettings(this);
 
   FCustomCommandsScrollOnDragOver = new TListViewScrollOnDragOver(CustomCommandsView, true);
@@ -145,6 +146,13 @@ bool __fastcall TPreferencesDialog::Execute(TPreferencesDialogData * DialogData)
     SaveConfiguration();
     CustomWinConfiguration->History[L"PuttyPath"] = PuttyPathEdit->Items;
   }
+  else
+  {
+    for (int Index = 0; Index < FAddedExtensions->Count; Index++)
+    {
+      DeleteFile(ApiPath(FAddedExtensions->Strings[Index]));
+    }
+  }
   return Result;
 }
 //---------------------------------------------------------------------------
@@ -2527,6 +2535,7 @@ void __fastcall TPreferencesDialog::AddExtension()
           Abort();
         }
         Lines->SaveToFile(ExtensionPath);
+        FAddedExtensions->Add(ExtensionPath);
       }
 
       int Index = GetListCommandIndex(FExtensionList);

+ 1 - 0
source/forms/Preferences.h

@@ -425,6 +425,7 @@ private:
   bool FAutomaticUpdatesPossible;
   TWndMethod FOrigCustomCommandsViewWindowProc;
   int FCustomCommandsHintItem;
+  std::unique_ptr<TStrings> FAddedExtensions;
   void __fastcall CMDialogKey(TWMKeyDown & Message);
   void __fastcall WMHelp(TWMHelp & Message);
   UnicodeString __fastcall TabSample(UnicodeString Values);