diff --git a/ide/sourceeditor.pp b/ide/sourceeditor.pp index 38e1f90b8d..5c24df93da 100644 --- a/ide/sourceeditor.pp +++ b/ide/sourceeditor.pp @@ -5554,9 +5554,8 @@ begin // add recent tabs. skip 0 since that is the active tab for i := 1 to Min(10, FHistoryList.Count-1) do begin - //HistoryGetTopPageIndex; - EditorCur := FindSourceEditorWithPageIndex(TTabSheet(FHistoryList[i]).PageIndex); - if not EditorCur.FEditor.HandleAllocated then continue; // show only if it was visited + EditorCur := FindSourceEditorWithPageIndex(FNotebook.IndexOf(TCustomPage(FHistoryList[i]))); + if (EditorCur = nil) or (not EditorCur.FEditor.HandleAllocated) then continue; // show only if it was visited AddEditorToMenuSection(EditorCur, RecMenu, i); RecMenu.Visible := True; end; @@ -6319,12 +6318,12 @@ end; procedure TSourceNotebook.NoteBookDeletePage(APageIndex: Integer); begin + HistoryRemove(FNotebook.Pages[APageIndex]); if PageCount > 1 then begin // make sure to select another page in the NoteBook, otherwise the // widgetset will choose one and will send a message // if this is the current page, switch to right APageIndex (if possible) //todo: determine whether we can use SetPageIndex instead - HistoryRemove(FNotebook.Pages[APageIndex]); if PageIndex = APageIndex then begin if EditorOpts.UseTabHistory then FPageIndex := HistoryGetTopPageIndex