IDE: Prevent running a library project. Disable also other Run menu items when they can't be used. Fixes #17974

git-svn-id: trunk@28346 -
This commit is contained in:
juha 2010-11-19 12:16:26 +00:00
parent 2c5a3921bf
commit f4f719b5eb
2 changed files with 24 additions and 29 deletions

View File

@ -2190,40 +2190,37 @@ begin
// For 'run' and 'step' bypass 'idle', so we can set the filename later // For 'run' and 'step' bypass 'idle', so we can set the filename later
CanRun:=false; CanRun:=false;
if Project1<>nil then if Project1<>nil then
begin CanRun:=((AnUnitInfo<>nil) and (AnUnitInfo.RunFileIfActive)) or
if (AnUnitInfo<>nil) and (AnUnitInfo.RunFileIfActive) then ((Project1.CompilerOptions.ExecutableType=cetProgram)
CanRun:=true and (pfRunnable in Project1.Flags));
else if pfRunnable in Project1.Flags then RunSpeedButton.Enabled := CanRun and (DebuggerInvalid
CanRun:=true; or (dcRun in FDebugger.Commands) or (FDebugger.State = dsIdle));
end;
RunSpeedButton.Enabled := CanRun
and (DebuggerInvalid
or (dcRun in FDebugger.Commands) or (FDebugger.State = dsIdle));
itmRunMenuRun.Enabled := RunSpeedButton.Enabled; itmRunMenuRun.Enabled := RunSpeedButton.Enabled;
PauseSpeedButton.Enabled := (not DebuggerInvalid) PauseSpeedButton.Enabled := CanRun
and (dcPause in FDebugger.Commands); and (not DebuggerInvalid) and (dcPause in FDebugger.Commands);
itmRunMenuPause.Enabled := PauseSpeedButton.Enabled; itmRunMenuPause.Enabled := PauseSpeedButton.Enabled;
itmRunMenuShowExecutionPoint.Enabled := (not DebuggerInvalid) and (FDebugger.State = dsPause); itmRunMenuShowExecutionPoint.Enabled := CanRun
StepIntoSpeedButton.Enabled := DebuggerInvalid and (not DebuggerInvalid) and (FDebugger.State = dsPause);
or (dcStepInto in FDebugger.Commands) or (FDebugger.State = dsIdle); StepIntoSpeedButton.Enabled := CanRun and (DebuggerInvalid
or (dcStepInto in FDebugger.Commands) or (FDebugger.State = dsIdle));
itmRunMenuStepInto.Enabled := StepIntoSpeedButton.Enabled; itmRunMenuStepInto.Enabled := StepIntoSpeedButton.Enabled;
StepOverSpeedButton.Enabled := DebuggerInvalid or StepOverSpeedButton.Enabled := CanRun and (DebuggerInvalid or
(dcStepOver in FDebugger.Commands) or (FDebugger.State = dsIdle); (dcStepOver in FDebugger.Commands) or (FDebugger.State = dsIdle));
itmRunMenuStepOver.Enabled := StepOverSpeedButton.Enabled; itmRunMenuStepOver.Enabled := StepOverSpeedButton.Enabled;
StepOutSpeedButton.Enabled := DebuggerInvalid or StepOutSpeedButton.Enabled := CanRun and (DebuggerInvalid or
(dcStepOut in FDebugger.Commands) or (FDebugger.State = dsIdle); (dcStepOut in FDebugger.Commands) or (FDebugger.State = dsIdle));
itmRunMenuStepOut.Enabled := StepOutSpeedButton.Enabled; itmRunMenuStepOut.Enabled := StepOutSpeedButton.Enabled;
itmRunMenuRunToCursor.Enabled := DebuggerInvalid itmRunMenuRunToCursor.Enabled := CanRun
or (dcRunTo in FDebugger.Commands); and (DebuggerInvalid or (dcRunTo in FDebugger.Commands));
itmRunMenuStop.Enabled := not DebuggerInvalid; itmRunMenuStop.Enabled := CanRun and not DebuggerInvalid;
StopSpeedButton.Enabled := itmRunMenuStop.Enabled; StopSpeedButton.Enabled := itmRunMenuStop.Enabled;
itmRunMenuEvaluate.Enabled := (not DebuggerInvalid) itmRunMenuEvaluate.Enabled := CanRun and (not DebuggerInvalid)
and (dcEvaluate in FDebugger.Commands); and (dcEvaluate in FDebugger.Commands);
SrcEditMenuEvaluateModify.Enabled := (not DebuggerInvalid) SrcEditMenuEvaluateModify.Enabled := CanRun and (not DebuggerInvalid)
and (dcEvaluate in FDebugger.Commands); and (dcEvaluate in FDebugger.Commands);
SrcEditMenuInspect.Enabled := (not DebuggerInvalid) SrcEditMenuInspect.Enabled := CanRun and (not DebuggerInvalid)
and (dcEvaluate in FDebugger.Commands); and (dcEvaluate in FDebugger.Commands);
itmRunMenuAddWatch.Enabled := True; // always allow to add a watch itmRunMenuAddWatch.Enabled := True; // always allow to add a watch

View File

@ -11097,14 +11097,12 @@ begin
// Check if we can run this project // Check if we can run this project
debugln('TMainIDE.DoInitProjectRun A ',dbgs(pfRunnable in Project1.Flags),' ',dbgs(Project1.MainUnitID)); debugln('TMainIDE.DoInitProjectRun A ',dbgs(pfRunnable in Project1.Flags),' ',dbgs(Project1.MainUnitID));
if (not (pfRunnable in Project1.Flags)) if not ((Project1.CompilerOptions.ExecutableType=cetProgram) and
or (Project1.MainUnitID < 0) (pfRunnable in Project1.Flags) and (Project1.MainUnitID >= 0)) then Exit;
then Exit;
debugln('TMainIDE.DoInitProjectRun B'); debugln('TMainIDE.DoInitProjectRun B');
// Build project first // Build project first
if DoBuildProject(crRun,[pbfOnlyIfNeeded]) <> mrOk if DoBuildProject(crRun,[pbfOnlyIfNeeded]) <> mrOk then Exit;
then Exit;
// Check project build // Check project build
ProgramFilename := MainBuildBoss.GetProjectTargetFilename(Project1); ProgramFilename := MainBuildBoss.GetProjectTargetFilename(Project1);