IDE: disable run speed button if project and file not runnable

git-svn-id: trunk@28051 -
This commit is contained in:
mattias 2010-11-03 09:36:26 +00:00
parent ec803db711
commit c94957e49b
2 changed files with 18 additions and 4 deletions

View File

@ -2060,15 +2060,29 @@ end;
procedure TDebugManager.UpdateButtonsAndMenuItems;
var
DebuggerInvalid: boolean;
CanRun: Boolean;
SrcEdit: TSourceEditorInterface;
AnUnitInfo: TUnitInfo;
begin
if (MainIDE=nil) or (MainIDE.ToolStatus = itExiting)
then exit;
DebuggerInvalid:=(FDebugger=nil) or (MainIDE.ToolStatus<>itDebugger);
MainIDE.GetCurrentUnitInfo(SrcEdit,AnUnitInfo);
with MainIDEBar do begin
// For 'run' and 'step' bypass 'idle', so we can set the filename later
RunSpeedButton.Enabled := DebuggerInvalid
or (dcRun in FDebugger.Commands) or (FDebugger.State = dsIdle);
CanRun:=false;
if Project1<>nil then
begin
if (AnUnitInfo<>nil) and (AnUnitInfo.RunFileIfActive) then
CanRun:=true
else if pfRunnable in Project1.Flags then
CanRun:=true;
debugln(['TDebugManager.UpdateButtonsAndMenuItems ',pfRunnable in Project1.Flags]);
end;
RunSpeedButton.Enabled := CanRun
and (DebuggerInvalid
or (dcRun in FDebugger.Commands) or (FDebugger.State = dsIdle));
itmRunMenuRun.Enabled := RunSpeedButton.Enabled;
PauseSpeedButton.Enabled := (not DebuggerInvalid)
and (dcPause in FDebugger.Commands);
@ -2100,8 +2114,6 @@ begin
// menu view
itmViewRegisters.Enabled := (not DebuggerInvalid);
itmViewAssembler.Enabled := (not DebuggerInvalid);
// TODO: add other debugger menuitems
// TODO: implement by actions
end;
end;

View File

@ -16087,6 +16087,8 @@ begin
MainIDEBar.itmViewToggleFormUnit.Enabled := HasResources;
end;
MainIDEBar.ToggleFormSpeedBtn.Enabled := MainIDEBar.itmViewToggleFormUnit.Enabled;
DebugBoss.UpdateButtonsAndMenuItems;
end;
end;