SourceEdit: Do not access outdated tab-history entries (dangling pointers). Issue #0021939

git-svn-id: trunk@37195 -
This commit is contained in:
martin 2012-05-06 10:40:09 +00:00
parent 19e4380062
commit b66752bd74

View File

@ -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