From e2207e76a9cdc17d40901e2e8cf6fc3e6bb46633 Mon Sep 17 00:00:00 2001 From: Juha Date: Tue, 1 Jul 2025 12:25:39 +0300 Subject: [PATCH] ToDoList: Prevent a memory leak. --- components/todolist/tododlg.pas | 15 ++++++++------- ide/frames/compiler_modematrix.pas | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/components/todolist/tododlg.pas b/components/todolist/tododlg.pas index 89b9d96a2b..d4b88b73dc 100644 --- a/components/todolist/tododlg.pas +++ b/components/todolist/tododlg.pas @@ -87,7 +87,7 @@ procedure CreateIDEToDoWindow(Sender: TObject; aFormName: string; var AForm: TCustomForm; DoDisableAutoSizing: boolean); // ToDo Dialog function ExecuteTodoDialog(const aCaption: string; var aTodoItem: TTodoItem): TModalResult; -procedure InsertToDoForActiveSE(aSrcEdit: TSourceEditorInterface); +procedure InsertToDo(aSrcEdit: TSourceEditorInterface); procedure EditToDo(aTodoItem: TTodoItem; aSrcEdit: TSourceEditorInterface); procedure InsertOrEditToDo(Sender: TObject); @@ -223,7 +223,7 @@ begin aTodoDialog.Free; end; -procedure InsertToDoForActiveSE(aSrcEdit: TSourceEditorInterface); +procedure InsertToDo(aSrcEdit: TSourceEditorInterface); var TodoItem: TTodoItem; begin @@ -244,8 +244,6 @@ begin if ExecuteTodoDialog(lisTDDEditToDo, aTodoItem) <> mrOK then exit; aSrcEdit.SelectText(aTodoItem.StartPos, aTodoItem.EndPos); aSrcEdit.Selection := aTodoItem.AsComment; - if aTodoItem.Temporary then - aTodoItem.Free; if Assigned(IDETodoWindow) then IDETodoWindow.UpdateTodos; { TODO -oJuha : Retain selection in the list. } end; @@ -256,10 +254,13 @@ var begin SrcEdit := SourceEditorManagerIntf.ActiveEditor; if (SrcEdit=nil) or SrcEdit.ReadOnly then exit; - if Assigned(TodoItemToEdit) then - EditToDo(TodoItemToEdit, SrcEdit) + if Assigned(TodoItemToEdit) then begin + EditToDo(TodoItemToEdit, SrcEdit); + if TodoItemToEdit.Temporary then + FreeAndNil(TodoItemToEdit); + end else - InsertToDoForActiveSE(SrcEdit) + InsertToDo(SrcEdit) end; { TTodoDialog } diff --git a/ide/frames/compiler_modematrix.pas b/ide/frames/compiler_modematrix.pas index fb56a30e6a..71388021fa 100644 --- a/ide/frames/compiler_modematrix.pas +++ b/ide/frames/compiler_modematrix.pas @@ -502,7 +502,8 @@ begin Value:=GetCaptionValue(ValueMenuItem.Caption,fCaptionPatternMacroValue); Value:=DisplayNameToDirName(Value); CreateNewOption(BuildMatrixOptionTypeCaption(bmotIDEMacro),'LCLWidgetType:='+Value); - // Update LCLWidgetType to Config and Target page. ToDo: update also when deleting or changing. + // Update LCLWidgetType to Config and Target page. + // ToDo: update also when deleting or changing. TargetFrame := TCompilerConfigTargetFrame(FDialog.FindEditor(TCompilerConfigTargetFrame)); Assert(Assigned(TargetFrame)); TargetFrame.UpdateWidgetSet(Value);