Commit 20487798 authored by Martin's avatar Martin
Browse files

SourceEditor: Fix an issue with focusing an editor, that is being closed...

SourceEditor: Fix an issue with focusing an editor, that is being closed (while debugging) "no parent handle". Issue #22015

git-svn-id: trunk@37471 -
parent 987fd9b7
......@@ -5906,15 +5906,20 @@ begin
DebugLnEnter(SRCED_PAGES, ['>> TSourceNotebook.SetPageIndex Cur-PgIdx=', PageIndex, ' FPageIndex=', FPageIndex, ' Value=', AValue, ' FUpdateLock=', FUpdateLock]);
FPageIndex := AValue;
if FUpdateLock = 0 then begin
FPageIndex := Max(0, Min(FPageIndex, FNotebook.PageCount-1));
if Assigned(Manager) and (FNotebook.PageIndex = FPageIndex) then
DoActiveEditorChanged;
// make sure the statusbar is updated
Include(States, snNotbookPageChangedNeeded);
FNotebook.PageIndex := FPageIndex;
if snNotbookPageChangedNeeded in States then
NotebookPageChanged(nil);
HistorySetMostRecent(FNotebook.Pages[FPageIndex]);
DebugBoss.LockCommandProcessing;
try
FPageIndex := Max(0, Min(FPageIndex, FNotebook.PageCount-1));
if Assigned(Manager) and (FNotebook.PageIndex = FPageIndex) then
DoActiveEditorChanged;
// make sure the statusbar is updated
Include(States, snNotbookPageChangedNeeded);
FNotebook.PageIndex := FPageIndex;
if snNotbookPageChangedNeeded in States then
NotebookPageChanged(nil);
HistorySetMostRecent(FNotebook.Pages[FPageIndex]);
finally
DebugBoss.UnLockCommandProcessing;
end;
end;
DebugLnExit(SRCED_PAGES, ['<< TSourceNotebook.SetPageIndex ']);
end;
......@@ -7467,44 +7472,49 @@ Begin
end;
DebugLnEnter(SRCED_PAGES, ['>> TSourceNotebook.NotebookPageChanged PageIndex=', PageIndex, ' AutoFocusLock=', fAutoFocusLock]);
Exclude(States, snNotbookPageChangedNeeded);
TempEditor:=GetActiveSE;
if (FHintWindow <> nil) and FHintWindow.Visible then
HideHint;
DebugBoss.LockCommandProcessing;
try
Exclude(States, snNotbookPageChangedNeeded);
TempEditor:=GetActiveSE;
if (FHintWindow <> nil) and FHintWindow.Visible then
HideHint;
DebugLn(SRCED_PAGES, ['TSourceNotebook.NotebookPageChanged TempEdit=', DbgSName(TempEditor)]);
if TempEditor <> nil then
begin
if not TempEditor.Visible then begin
// As long as SynEdit had no Handle, it had kept all those Values untouched
CaretXY := TempEditor.EditorComponent.CaretXY;
TopLine := TempEditor.EditorComponent.TopLine;
TempEditor.BeginUpdate;
TempEditor.Visible := True;
TempEditor.EndUpdate;
// Restore the intial Positions, must be after lock
TempEditor.EditorComponent.LeftChar := 1;
TempEditor.EditorComponent.CaretXY := CaretXY;
TempEditor.EditorComponent.TopLine := TopLine;
end;
if (fAutoFocusLock=0) and (Screen.ActiveCustomForm=GetParentForm(Self)) and
not(Manager.HasAutoFocusLock)
then
DebugLn(SRCED_PAGES, ['TSourceNotebook.NotebookPageChanged TempEdit=', DbgSName(TempEditor)]);
if TempEditor <> nil then
begin
DebugLnEnter(SRCED_PAGES, ['TSourceNotebook.NotebookPageChanged BEFORE SetFocus ', DbgSName(TempEditor.EditorComponent),' Page=', FindPageWithEditor(TempEditor), ' ', TempEditor.FileName]);
TempEditor.FocusEditor; // recursively calls NotebookPageChanged, via EditorEnter
DebugLnExit(SRCED_PAGES, ['TSourceNotebook.NotebookPageChanged AFTER SetFocus ', DbgSName(TempEditor.EditorComponent),' Page=', FindPageWithEditor(TempEditor)]);
if not TempEditor.Visible then begin
// As long as SynEdit had no Handle, it had kept all those Values untouched
CaretXY := TempEditor.EditorComponent.CaretXY;
TopLine := TempEditor.EditorComponent.TopLine;
TempEditor.BeginUpdate;
TempEditor.Visible := True;
TempEditor.EndUpdate;
// Restore the intial Positions, must be after lock
TempEditor.EditorComponent.LeftChar := 1;
TempEditor.EditorComponent.CaretXY := CaretXY;
TempEditor.EditorComponent.TopLine := TopLine;
end;
if (fAutoFocusLock=0) and (Screen.ActiveCustomForm=GetParentForm(Self)) and
not(Manager.HasAutoFocusLock)
then
begin
DebugLnEnter(SRCED_PAGES, ['TSourceNotebook.NotebookPageChanged BEFORE SetFocus ', DbgSName(TempEditor.EditorComponent),' Page=', FindPageWithEditor(TempEditor), ' ', TempEditor.FileName]);
TempEditor.FocusEditor; // recursively calls NotebookPageChanged, via EditorEnter
DebugLnExit(SRCED_PAGES, ['TSourceNotebook.NotebookPageChanged AFTER SetFocus ', DbgSName(TempEditor.EditorComponent),' Page=', FindPageWithEditor(TempEditor)]);
end;
UpdateStatusBar;
UpdateActiveEditColors(TempEditor.EditorComponent);
if (DebugBoss.State in [dsPause, dsRun]) and
not TempEditor.HasExecutionMarks and
(TempEditor.FileName <> '') then
TempEditor.FillExecutionMarks;
DoActiveEditorChanged;
end;
UpdateStatusBar;
UpdateActiveEditColors(TempEditor.EditorComponent);
if (DebugBoss.State in [dsPause, dsRun]) and
not TempEditor.HasExecutionMarks and
(TempEditor.FileName <> '') then
TempEditor.FillExecutionMarks;
DoActiveEditorChanged;
end;
CheckCurrentCodeBufferChanged;
CheckCurrentCodeBufferChanged;
finally
DebugBoss.UnLockCommandProcessing;
end;
DebugLnExit(SRCED_PAGES, ['<< TSourceNotebook.NotebookPageChanged ']);
end;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment