Просмотр исходного кода

When removing extension added in the same "preferences session", do not forget to remove the extension file too

Source commit: fa2771fb2ce5ed0935272c2a9d29898fda28299a
Martin Prikryl 9 лет назад
Родитель
Сommit
ea6c87e41e
1 измененных файлов с 13 добавлено и 1 удалено
  1. 13 1
      source/forms/Preferences.cpp

+ 13 - 1
source/forms/Preferences.cpp

@@ -75,7 +75,7 @@ __fastcall TPreferencesDialog::TPreferencesDialog(
   FEditorList = new TEditorList();
   FAutomaticUpdatesPossible = IsInstalled();
   FCustomCommandsHintItem = NULL;
-  FAddedExtensions.reset(new TStringList());
+  FAddedExtensions.reset(CreateSortedStringList());
   UseSystemSettings(this);
 
   FCustomCommandsScrollOnDragOver = new TListViewScrollOnDragOver(CustomCommandsView, true);
@@ -1503,6 +1503,18 @@ void __fastcall TPreferencesDialog::RemoveCommandButtonClick(
 {
   TCustomCommandList * List = GetCommandList(CustomCommandsView->ItemIndex);
   int Index = GetCommandIndex(CustomCommandsView->ItemIndex);
+  if (List == FExtensionList)
+  {
+    const TCustomCommandType * CustomComand = List->Commands[Index];
+
+    // If the extension was added in this "preferences session", remove the file
+    int PathIndex = FAddedExtensions->IndexOf(CustomComand->FileName);
+    if (PathIndex >= 0)
+    {
+      FAddedExtensions->Delete(PathIndex);
+      DeleteFile(ApiPath(CustomComand->FileName));
+    }
+  }
   List->Delete(Index);
   UpdateCustomCommandsView();
   UpdateControls();