mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 11:40:49 +02:00
IDE: project options cancel: restore SessionModified flag, bug #18143
git-svn-id: trunk@28607 -
This commit is contained in:
parent
02c56dd013
commit
7575b21454
61
ide/main.pp
61
ide/main.pp
@ -853,7 +853,7 @@ type
|
||||
procedure DoQuickCompile;
|
||||
function DoInitProjectRun: TModalResult; override;
|
||||
function DoRunProject: TModalResult;
|
||||
function SomethingOfProjectIsModified: boolean;
|
||||
function SomethingOfProjectIsModified(Verbose: boolean = false): boolean;
|
||||
function DoCreateProjectForProgram(ProgramBuf: TCodeBuffer): TModalResult;
|
||||
function DoSaveProjectIfChanged: TModalResult;
|
||||
function DoSaveProjectToTestDirectory(Flags: TSaveFlags): TModalResult;
|
||||
@ -4667,6 +4667,7 @@ begin
|
||||
//debugln(['TMainIDE.DoProjectOptionsBeforeRead ',DbgSName(Sender)]);
|
||||
BeginCodeTool(ActiveSrcEdit, ActiveUnitInfo, []);
|
||||
AProject:=TProject(Sender);
|
||||
AProject.BackupSession;
|
||||
AProject.BackupBuildModes;
|
||||
AProject.UpdateExecutableType;
|
||||
AProject.CompilerOptions.UseAsDefault := False;
|
||||
@ -4675,15 +4676,15 @@ end;
|
||||
procedure TMainIDE.DoProjectOptionsAfterWrite(Sender: TObject; Restore: boolean
|
||||
);
|
||||
var
|
||||
Project: TProject absolute Sender;
|
||||
AProject: TProject absolute Sender;
|
||||
aFilename: String;
|
||||
|
||||
function GetTitle: String;
|
||||
begin
|
||||
Result := '';
|
||||
if (Project = nil) or (Project.MainUnitID < 0) then
|
||||
if (AProject = nil) or (AProject.MainUnitID < 0) then
|
||||
Exit;
|
||||
CodeToolBoss.GetApplicationTitleStatement(Project.MainUnitInfo.Source, Result);
|
||||
CodeToolBoss.GetApplicationTitleStatement(AProject.MainUnitInfo.Source, Result);
|
||||
end;
|
||||
|
||||
function SetTitle: Boolean;
|
||||
@ -4691,15 +4692,15 @@ var
|
||||
OldTitle: String;
|
||||
begin
|
||||
Result := True;
|
||||
if (Project.MainUnitID < 0) or
|
||||
(not (pfMainUnitHasTitleStatement in Project.Flags)) then
|
||||
if (AProject.MainUnitID < 0) or
|
||||
(not (pfMainUnitHasTitleStatement in AProject.Flags)) then
|
||||
Exit;
|
||||
OldTitle := GetTitle;
|
||||
if (OldTitle = '') and Project.TitleIsDefault then
|
||||
if (OldTitle = '') and AProject.TitleIsDefault then
|
||||
Exit;
|
||||
|
||||
if (OldTitle <> Project.Title) and (not Project.TitleIsDefault) then
|
||||
if not CodeToolBoss.SetApplicationTitleStatement(Project.MainUnitInfo.Source, Project.Title) then
|
||||
if (OldTitle <> AProject.Title) and (not AProject.TitleIsDefault) then
|
||||
if not CodeToolBoss.SetApplicationTitleStatement(AProject.MainUnitInfo.Source, AProject.Title) then
|
||||
begin
|
||||
MessageDlg(lisProjOptsError,
|
||||
'Unable to change project title in source.'#13 +
|
||||
@ -4709,8 +4710,8 @@ var
|
||||
Exit;
|
||||
end;// set Application.Title:= statement
|
||||
|
||||
if (OldTitle <> '') and Project.TitleIsDefault then
|
||||
if not CodeToolBoss.RemoveApplicationTitleStatement(Project.MainUnitInfo.Source) then
|
||||
if (OldTitle <> '') and AProject.TitleIsDefault then
|
||||
if not CodeToolBoss.RemoveApplicationTitleStatement(AProject.MainUnitInfo.Source) then
|
||||
begin
|
||||
MessageDlg(lisProjOptsError,
|
||||
'Unable to remove project title from source.'#13 +
|
||||
@ -4727,26 +4728,26 @@ var
|
||||
OldList: TStrings;
|
||||
begin
|
||||
Result := True;
|
||||
if (Project.MainUnitID < 0) or
|
||||
(not (pfMainUnitHasUsesSectionForAllUnits in Project.Flags)) then
|
||||
if (AProject.MainUnitID < 0) or
|
||||
(not (pfMainUnitHasUsesSectionForAllUnits in AProject.Flags)) then
|
||||
Exit;
|
||||
OldList := Project.GetAutoCreatedFormsList;
|
||||
OldList := AProject.GetAutoCreatedFormsList;
|
||||
if (OldList = nil) then
|
||||
Exit;
|
||||
try
|
||||
if OldList.Count = Project.TmpAutoCreatedForms.Count then
|
||||
if OldList.Count = AProject.TmpAutoCreatedForms.Count then
|
||||
begin
|
||||
|
||||
{ Just exit if the form list is the same }
|
||||
i := OldList.Count - 1;
|
||||
while (i >= 0) and (SysUtils.CompareText(OldList[i], Project.TmpAutoCreatedForms[i]) = 0) do
|
||||
while (i >= 0) and (SysUtils.CompareText(OldList[i], AProject.TmpAutoCreatedForms[i]) = 0) do
|
||||
Dec(i);
|
||||
if i < 0 then
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if not CodeToolBoss.SetAllCreateFromStatements(Project.MainUnitInfo.Source,
|
||||
Project.TmpAutoCreatedForms) then
|
||||
if not CodeToolBoss.SetAllCreateFromStatements(AProject.MainUnitInfo.Source,
|
||||
AProject.TmpAutoCreatedForms) then
|
||||
begin
|
||||
MessageDlg(lisProjOptsError,
|
||||
Format(lisProjOptsUnableToChangeTheAutoCreateFormList, [LineEnding]),
|
||||
@ -4766,26 +4767,28 @@ begin
|
||||
SetTitle;
|
||||
SetAutoCreateForms;
|
||||
// extend include path
|
||||
Project.AutoAddOutputDirToIncPath;
|
||||
if Project.Resources.Modified and (Project.MainUnitID >= 0) then
|
||||
AProject.AutoAddOutputDirToIncPath;
|
||||
if AProject.Resources.Modified and (AProject.MainUnitID >= 0) then
|
||||
begin
|
||||
if not Project.Resources.Regenerate(Project.MainFilename, True, False, '') then
|
||||
MessageDlg(Project.Resources.Messages.Text, mtWarning, [mbOk], 0);
|
||||
if not AProject.Resources.Regenerate(AProject.MainFilename, True, False, '') then
|
||||
MessageDlg(AProject.Resources.Messages.Text, mtWarning, [mbOk], 0);
|
||||
end;
|
||||
UpdateCaption;
|
||||
Project.DefineTemplates.AllChanged;
|
||||
AProject.DefineTemplates.AllChanged;
|
||||
end;
|
||||
if Restore then
|
||||
Project.RestoreBuildModes;
|
||||
AProject.RestoreBuildModes;
|
||||
IncreaseCompilerParseStamp;
|
||||
MainBuildBoss.SetBuildTarget(Project1.CompilerOptions.TargetOS,
|
||||
Project1.CompilerOptions.TargetCPU,Project1.CompilerOptions.LCLWidgetType,
|
||||
bmsfsBackground);
|
||||
if (not Restore) and Project.CompilerOptions.UseAsDefault then
|
||||
if (not Restore) and AProject.CompilerOptions.UseAsDefault then
|
||||
begin
|
||||
aFilename:=AppendPathDelim(GetPrimaryConfigPath)+DefaultProjectCompilerOptionsFilename;
|
||||
Project.CompilerOptions.SaveToFile(aFilename);
|
||||
AProject.CompilerOptions.SaveToFile(aFilename);
|
||||
end;
|
||||
if Restore then
|
||||
AProject.RestoreSession;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.mnuEnvEditorOptionsClicked(Sender: TObject);
|
||||
@ -11272,11 +11275,11 @@ begin
|
||||
DebugLn('[TMainIDE.DoRunProject] END');
|
||||
end;
|
||||
|
||||
function TMainIDE.SomethingOfProjectIsModified: boolean;
|
||||
function TMainIDE.SomethingOfProjectIsModified(Verbose: boolean): boolean;
|
||||
begin
|
||||
Result:=(Project1<>nil)
|
||||
and (Project1.SomethingModified(true,true)
|
||||
or SourceEditorManager.SomethingModified);
|
||||
and (Project1.SomethingModified(true,true,Verbose)
|
||||
or SourceEditorManager.SomethingModified(Verbose));
|
||||
end;
|
||||
|
||||
function TMainIDE.DoSaveAll(Flags: TSaveFlags): TModalResult;
|
||||
|
@ -785,6 +785,7 @@ type
|
||||
FResources: TProjectResources;
|
||||
FRevertLockCount: integer;
|
||||
FRunParameterOptions: TRunParamsOptions;
|
||||
FSessionModifiedBackup: boolean;
|
||||
FSessionStorePathDelim: TPathDelimSwitch;
|
||||
FSkipCheckLCLInterfaces: boolean;
|
||||
FSourceDirectories: TFileReferenceList;
|
||||
@ -866,9 +867,9 @@ type
|
||||
|
||||
// load/save
|
||||
function IsVirtual: boolean;
|
||||
function SomethingModified(CheckData, CheckSession: boolean): boolean;
|
||||
function SomeDataModified: boolean;
|
||||
function SomeSessionModified: boolean;
|
||||
function SomethingModified(CheckData, CheckSession: boolean; Verbose: boolean = false): boolean;
|
||||
function SomeDataModified(Verbose: boolean = false): boolean;
|
||||
function SomeSessionModified(Verbose: boolean = false): boolean;
|
||||
procedure MainSourceFilenameChanged;
|
||||
procedure GetUnitsChangedOnDisk(var AnUnitList: TFPList);
|
||||
function HasProjectInfoFileChangedOnDisk: boolean;
|
||||
@ -877,6 +878,8 @@ type
|
||||
function WriteProject(ProjectWriteFlags: TProjectWriteFlags;
|
||||
const OverrideProjectInfoFile: string): TModalResult;
|
||||
procedure UpdateExecutableType; override;
|
||||
procedure BackupSession;
|
||||
procedure RestoreSession;
|
||||
procedure BackupBuildModes;
|
||||
procedure RestoreBuildModes;
|
||||
|
||||
@ -3012,6 +3015,16 @@ begin
|
||||
ExecutableType:=petNone;
|
||||
end;
|
||||
|
||||
procedure TProject.BackupSession;
|
||||
begin
|
||||
FSessionModifiedBackup:=SessionModified;
|
||||
end;
|
||||
|
||||
procedure TProject.RestoreSession;
|
||||
begin
|
||||
SessionModified:=FSessionModifiedBackup;
|
||||
end;
|
||||
|
||||
procedure TProject.BackupBuildModes;
|
||||
begin
|
||||
FActiveBuildModeBackup:=BuildModes.IndexOf(ActiveBuildMode);
|
||||
@ -5168,77 +5181,71 @@ begin
|
||||
Result:=(i>=0) and (Units[i].OpenEditorInfoCount > 0);
|
||||
end;
|
||||
|
||||
function TProject.SomethingModified(CheckData, CheckSession: boolean): boolean;
|
||||
function TProject.SomethingModified(CheckData, CheckSession: boolean;
|
||||
Verbose: boolean): boolean;
|
||||
begin
|
||||
Result := True;
|
||||
if CheckData and SomeDataModified then exit;
|
||||
if CheckSession and SomeSessionModified then exit;
|
||||
if CheckData and SomeDataModified(Verbose) then exit;
|
||||
if CheckSession and SomeSessionModified(Verbose) then exit;
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
function TProject.SomeDataModified: boolean;
|
||||
function TProject.SomeDataModified(Verbose: boolean): boolean;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result:=true;
|
||||
if Modified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomeDataModified Modified');
|
||||
{$ENDIF}
|
||||
if Verbose then
|
||||
DebugLn('TProject.SomeDataModified Modified');
|
||||
Exit;
|
||||
end;
|
||||
if BuildModes.IsModified(false) then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn(['TProject.SomeDataModified CompilerOptions/BuildModes']);
|
||||
{$ENDIF}
|
||||
if Verbose then
|
||||
DebugLn(['TProject.SomeDataModified CompilerOptions/BuildModes']);
|
||||
Exit;
|
||||
end;
|
||||
for i := 0 to UnitCount - 1 do
|
||||
if (Units[i].IsPartOfProject) and Units[i].Modified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomeDataModified PartOfProject ',Units[i].Filename);
|
||||
{$ENDIF}
|
||||
if Verbose then
|
||||
DebugLn('TProject.SomeDataModified PartOfProject ',Units[i].Filename);
|
||||
Exit;
|
||||
end;
|
||||
Result:=false;
|
||||
end;
|
||||
|
||||
function TProject.SomeSessionModified: boolean;
|
||||
function TProject.SomeSessionModified(Verbose: boolean): boolean;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result:=true;
|
||||
if SessionModified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomeSessionModified SessionModified');
|
||||
{$ENDIF}
|
||||
if Verbose then
|
||||
DebugLn('TProject.SomeSessionModified SessionModified');
|
||||
Exit;
|
||||
end;
|
||||
if BuildModes.IsModified(true) then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn(['TProject.SomeSessionModified CompilerOptions/BuildModes']);
|
||||
{$ENDIF}
|
||||
if Verbose then
|
||||
DebugLn(['TProject.SomeSessionModified CompilerOptions/BuildModes']);
|
||||
Exit;
|
||||
end;
|
||||
for i := 0 to UnitCount - 1 do
|
||||
begin
|
||||
if Units[i].SessionModified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomeSessionModified Session of ',Units[i].Filename);
|
||||
{$ENDIF}
|
||||
if Verbose then
|
||||
DebugLn('TProject.SomeSessionModified Session of ',Units[i].Filename);
|
||||
exit;
|
||||
end;
|
||||
if (not Units[i].IsPartOfProject) and Units[i].Modified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomeSessionModified Not PartOfProject ',Units[i].Filename);
|
||||
{$ENDIF}
|
||||
if Verbose then
|
||||
DebugLn('TProject.SomeSessionModified Not PartOfProject ',Units[i].Filename);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
@ -984,7 +984,7 @@ type
|
||||
procedure SetupShortCuts;
|
||||
|
||||
function FindUniquePageName(FileName:string; IgnoreEditor: TSourceEditor):string;
|
||||
function SomethingModified: boolean;
|
||||
function SomethingModified(Verbose: boolean = false): boolean;
|
||||
procedure HideHint;
|
||||
procedure OnIdle(Sender: TObject; var Done: Boolean);
|
||||
procedure LockAllEditorsInSourceChangeCache;
|
||||
@ -8514,12 +8514,20 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSourceEditorManager.SomethingModified: boolean;
|
||||
function TSourceEditorManager.SomethingModified(Verbose: boolean): boolean;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
for i:=0 to SourceEditorCount - 1 do
|
||||
begin
|
||||
if SourceEditors[i].Modified then
|
||||
begin
|
||||
if Verbose then
|
||||
debugln(['TSourceEditorManager.SomethingModified ',SourceEditors[i].FileName]);
|
||||
exit(true);
|
||||
end;
|
||||
end;
|
||||
Result:=false;
|
||||
for i:=0 to SourceEditorCount - 1 do Result := Result or SourceEditors[i].Modified;
|
||||
end;
|
||||
|
||||
procedure TSourceEditorManager.HideHint;
|
||||
|
Loading…
Reference in New Issue
Block a user