Commit 2e47a308 authored by Martin's avatar Martin 💬
Browse files

IDE: prevent debugger from entering invalid state, if started again before...

IDE: prevent debugger from entering invalid state, if started again before completely stopped. For info see issue #23800

git-svn-id: trunk@40097 -
parent c788e633
......@@ -137,6 +137,7 @@ type
procedure SetupMainBarShortCuts; virtual; abstract;
procedure SetupSourceMenuShortCuts; virtual; abstract;
procedure UpdateButtonsAndMenuItems; virtual; abstract;
procedure UpdateToolStatus; virtual; abstract;
procedure LoadProjectSpecificInfo(XMLConfig: TXMLConfig;
Merge: boolean); virtual; abstract;
......
......@@ -172,6 +172,7 @@ type
procedure SetupMainBarShortCuts; override;
procedure SetupSourceMenuShortCuts; override;
procedure UpdateButtonsAndMenuItems; override;
procedure UpdateToolStatus; override;
procedure LoadProjectSpecificInfo(XMLConfig: TXMLConfig;
Merge: boolean); override;
......@@ -1039,12 +1040,8 @@ procedure TDebugManager.DebuggerChangeState(ADebugger: TDebugger;
FDialogs[DialogType].EndUpdate;
end;
const
//const
// dsNone, dsIdle, dsStop, dsPause, dsInit, dsRun, dsError
TOOLSTATEMAP: array[TDBGState] of TIDEToolStatus = (
//dsNone, dsIdle, dsStop, dsPause, dsInternalPause, dsInit, dsRun, dsError, dsDestroying
itNone, itNone, itDebugger, itDebugger, itDebugger, itDebugger, itDebugger, itNone, itNone
);
//STATENAME: array[TDBGState] of string = (
// 'dsNone', 'dsIdle', 'dsStop', 'dsPause', 'dsInit', 'dsRun', 'dsError'
//);
......@@ -1100,8 +1097,7 @@ begin
UpdateButtonsAndMenuItems;
// Next may call ResetDebugger, then FDebugger is gone
if MainIDE.ToolStatus in [itNone,itDebugger]
then MainIDE.ToolStatus := TOOLSTATEMAP[FDebugger.State];
UpdateToolStatus;
FAutoContinueTimer.Enabled := false;
......@@ -1194,7 +1190,7 @@ begin
if EnvironmentOptions.DebuggerResetAfterRun then
ResetDebugger
else
FDebugger.FileName := '';
FDebugger.FileName := ''; // SetState(dsIdle) via ResetStateToIdle
if FDialogs[ddtAssembler] <> nil
then TAssemblerDlg(FDialogs[ddtAssembler]).SetLocation(nil, 0);
......@@ -1862,6 +1858,23 @@ begin
end;
end;
procedure TDebugManager.UpdateToolStatus;
const
TOOLSTATEMAP: array[TDBGState] of TIDEToolStatus = (
//dsNone, dsIdle, dsStop, dsPause, dsInternalPause, dsInit, dsRun, dsError, dsDestroying
itNone, itNone, itDebugger, itDebugger, itDebugger, itDebugger, itDebugger, itNone, itNone
);
begin
// Next may call ResetDebugger, then FDebugger is gone
if MainIDE.ToolStatus in [itNone,itDebugger]
then begin
if FDebugger = nil then
MainIDE.ToolStatus := itNone
else
MainIDE.ToolStatus := TOOLSTATEMAP[FDebugger.State];
end;
end;
{------------------------------------------------------------------------------
procedure TDebugManager.LoadProjectSpecificInfo(XMLConfig: TXMLConfig;
Merge: boolean);
......
......@@ -7004,6 +7004,7 @@ var
TargetExeDirectory: String;
FPCVersion, FPCRelease, FPCPatch: integer;
Note: String;
OldToolStatus: TIDEToolStatus;
begin
if (Project1=nil) or (Project1.MainUnitInfo=nil) then begin
// this project has no source to compile
......@@ -7214,6 +7215,7 @@ begin
and (not (pbfDoNotCompileProject in Flags)) then begin
try
// change tool status
OldToolStatus := ToolStatus; // It can still be itDebugger, if the debugger is still stopping. Prevent any "Run" command after building, until the debugger is clear
ToolStatus:=itBuilder;
ConnectOutputFilter;
......@@ -7267,7 +7269,13 @@ begin
end;
finally
ToolStatus:=itNone;
if OldToolStatus = itDebugger then begin
ToolStatus := OldToolStatus;
if DebugBoss <> nil then
DebugBoss.UpdateToolStatus; // Maybe "Reset Debugger was called and changed the state?
end
else
ToolStatus:=itNone;
end;
end;
......
Markdown is supported
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