IDE: Prevent AV when trying to record a macro with closed editors. Issue #28947.

git-svn-id: trunk@50214 -
This commit is contained in:
juha 2015-11-03 15:41:19 +00:00
parent c8cb925526
commit 1cefa33866

View File

@ -1037,9 +1037,12 @@ procedure TMacroListView.btnPlayClick(Sender: TObject);
var
i: Integer;
M: TEditorMacro;
se: TSourceEditorInterface;
begin
if ActiveEditorMacro <> nil then exit;
if lbRecordedView.ItemIndex < 0 then exit;
se := SourceEditorManagerIntf.ActiveEditor;
if se = nil then Exit;
i := 1;
if chkRepeat.Enabled then i := edRepeat.Value;
@ -1049,7 +1052,7 @@ begin
M := CurrentEditorMacroList.Macros[lbRecordedView.ItemIndex];
try
while i > 0 do begin
M.PlaybackMacro(TCustomSynEdit(SourceEditorManagerIntf.ActiveEditor.EditorControl));
M.PlaybackMacro(TCustomSynEdit(se.EditorControl));
Application.ProcessMessages;
dec(i);
if not FIsPlaying then break;
@ -1094,19 +1097,20 @@ begin
end;
procedure TMacroListView.btnRecordClick(Sender: TObject);
var
se: TSourceEditorInterface;
begin
if (ActiveEditorMacro = nil) and (EditorMacroForRecording.State = emStopped) then begin
EditorMacroForRecording.RecordMacro(TCustomSynEdit(SourceEditorManagerIntf.ActiveEditor.EditorControl));
end
se := SourceEditorManagerIntf.ActiveEditor;
if se = nil then Exit;
if (ActiveEditorMacro = nil) and (EditorMacroForRecording.State = emStopped) then
EditorMacroForRecording.RecordMacro(TCustomSynEdit(se.EditorControl))
else
if EditorMacroForRecording.State = emRecording then begin
EditorMacroForRecording.Pause;
end
if EditorMacroForRecording.State = emRecording then
EditorMacroForRecording.Pause
else
if EditorMacroForRecording.State = emRecPaused then begin
if EditorMacroForRecording.State = emRecPaused then
EditorMacroForRecording.Resume;
end;
SourceEditorManagerIntf.ActiveEditor.EditorControl.SetFocus;
se.EditorControl.SetFocus;
end;
procedure TMacroListView.btnRecordStopClick(Sender: TObject);
@ -1342,7 +1346,9 @@ begin
chkRepeat.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;
if (RecState = emRecording) then