mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 05:19:37 +02:00
IDE: Prevent AV when trying to record a macro with closed editors. Issue #28947.
git-svn-id: trunk@50214 -
This commit is contained in:
parent
c8cb925526
commit
1cefa33866
@ -1037,9 +1037,12 @@ procedure TMacroListView.btnPlayClick(Sender: TObject);
|
|||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
M: TEditorMacro;
|
M: TEditorMacro;
|
||||||
|
se: TSourceEditorInterface;
|
||||||
begin
|
begin
|
||||||
if ActiveEditorMacro <> nil then exit;
|
if ActiveEditorMacro <> nil then exit;
|
||||||
if lbRecordedView.ItemIndex < 0 then exit;
|
if lbRecordedView.ItemIndex < 0 then exit;
|
||||||
|
se := SourceEditorManagerIntf.ActiveEditor;
|
||||||
|
if se = nil then Exit;
|
||||||
|
|
||||||
i := 1;
|
i := 1;
|
||||||
if chkRepeat.Enabled then i := edRepeat.Value;
|
if chkRepeat.Enabled then i := edRepeat.Value;
|
||||||
@ -1049,7 +1052,7 @@ begin
|
|||||||
M := CurrentEditorMacroList.Macros[lbRecordedView.ItemIndex];
|
M := CurrentEditorMacroList.Macros[lbRecordedView.ItemIndex];
|
||||||
try
|
try
|
||||||
while i > 0 do begin
|
while i > 0 do begin
|
||||||
M.PlaybackMacro(TCustomSynEdit(SourceEditorManagerIntf.ActiveEditor.EditorControl));
|
M.PlaybackMacro(TCustomSynEdit(se.EditorControl));
|
||||||
Application.ProcessMessages;
|
Application.ProcessMessages;
|
||||||
dec(i);
|
dec(i);
|
||||||
if not FIsPlaying then break;
|
if not FIsPlaying then break;
|
||||||
@ -1094,19 +1097,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMacroListView.btnRecordClick(Sender: TObject);
|
procedure TMacroListView.btnRecordClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
se: TSourceEditorInterface;
|
||||||
begin
|
begin
|
||||||
if (ActiveEditorMacro = nil) and (EditorMacroForRecording.State = emStopped) then begin
|
se := SourceEditorManagerIntf.ActiveEditor;
|
||||||
EditorMacroForRecording.RecordMacro(TCustomSynEdit(SourceEditorManagerIntf.ActiveEditor.EditorControl));
|
if se = nil then Exit;
|
||||||
end
|
if (ActiveEditorMacro = nil) and (EditorMacroForRecording.State = emStopped) then
|
||||||
|
EditorMacroForRecording.RecordMacro(TCustomSynEdit(se.EditorControl))
|
||||||
else
|
else
|
||||||
if EditorMacroForRecording.State = emRecording then begin
|
if EditorMacroForRecording.State = emRecording then
|
||||||
EditorMacroForRecording.Pause;
|
EditorMacroForRecording.Pause
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if EditorMacroForRecording.State = emRecPaused then begin
|
if EditorMacroForRecording.State = emRecPaused then
|
||||||
EditorMacroForRecording.Resume;
|
EditorMacroForRecording.Resume;
|
||||||
end;
|
se.EditorControl.SetFocus;
|
||||||
SourceEditorManagerIntf.ActiveEditor.EditorControl.SetFocus;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMacroListView.btnRecordStopClick(Sender: TObject);
|
procedure TMacroListView.btnRecordStopClick(Sender: TObject);
|
||||||
@ -1342,7 +1346,9 @@ begin
|
|||||||
chkRepeat.Enabled := IsStopped and (not FIsPlaying);
|
chkRepeat.Enabled := IsStopped and (not FIsPlaying);
|
||||||
edRepeat.Enabled := IsStopped and (not FIsPlaying);
|
edRepeat.Enabled := IsStopped and (not FIsPlaying);
|
||||||
|
|
||||||
btnRecord.Enabled := (RecState in [emStopped, emRecPaused, emRecording]) and (not FIsPlaying);
|
btnRecord.Enabled := Assigned(SourceEditorManagerIntf.ActiveEditor)
|
||||||
|
and (RecState in [emStopped, emRecPaused, emRecording])
|
||||||
|
and (not FIsPlaying);
|
||||||
btnRecordStop.Enabled := (not IsStopped) or FIsPlaying;
|
btnRecordStop.Enabled := (not IsStopped) or FIsPlaying;
|
||||||
|
|
||||||
if (RecState = emRecording) then
|
if (RecState = emRecording) then
|
||||||
|
Loading…
Reference in New Issue
Block a user