mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 15:19:19 +02:00
IDE: fixed checking unit modify flags, bug #17315
git-svn-id: trunk@27331 -
This commit is contained in:
parent
55bb3e8ffe
commit
1c293c3104
@ -8270,6 +8270,8 @@ begin
|
||||
exit;
|
||||
end;
|
||||
AnUnitInfo := AnEditorInfo.UnitInfo;
|
||||
AnUnitInfo.SessionModified:=true;
|
||||
//debugln(['TMainIDE.DoCloseEditorFile File=',AnUnitInfo.Filename,' UnitSession=',AnUnitInfo.SessionModified,' ProjSession=',project1.SessionModified]);
|
||||
if AnUnitInfo.OpenEditorInfoCount > 1 then begin
|
||||
SourceEditorManager.CloseFile(AEditor);
|
||||
Result:=mrOk;
|
||||
|
127
ide/project.pp
127
ide/project.pp
@ -765,6 +765,8 @@ type
|
||||
// load/save
|
||||
function IsVirtual: boolean;
|
||||
function SomethingModified(CheckData, CheckSession: boolean): boolean;
|
||||
function SomeDataModified: boolean;
|
||||
function SomeSessionModified: boolean;
|
||||
procedure MainSourceFilenameChanged;
|
||||
procedure GetUnitsChangedOnDisk(var AnUnitList: TFPList);
|
||||
function HasProjectInfoFileChangedOnDisk: boolean;
|
||||
@ -2613,7 +2615,7 @@ begin
|
||||
// check if modified
|
||||
if not (pwfIgnoreModified in ProjectWriteFlags) then
|
||||
begin
|
||||
WriteLPI:=Modified or (not FileExistsUTF8(CfgFilename));
|
||||
WriteLPI:=SomeDataModified or (not FileExistsUTF8(CfgFilename));
|
||||
if (CompareFilenames(ProjectInfoFile,CfgFilename)=0) then begin
|
||||
// save to default lpi
|
||||
WriteLPI:=WriteLPI or (fProjectInfoFileDate<>FileAgeCached(CfgFilename));
|
||||
@ -2623,9 +2625,9 @@ begin
|
||||
end;
|
||||
if CurSessionFilename='' then begin
|
||||
WriteLPS:=false;
|
||||
WriteLPI:=WriteLPI or SessionModified;
|
||||
WriteLPI:=WriteLPI or SomeSessionModified;
|
||||
end else begin
|
||||
WriteLPS:=WriteLPI or SessionModified
|
||||
WriteLPS:=WriteLPI or SomeSessionModified
|
||||
or (not FileExistsUTF8(CurSessionFilename));
|
||||
end;
|
||||
if (not WriteLPI) and (not WriteLPS) then exit(mrOk);
|
||||
@ -2633,6 +2635,7 @@ begin
|
||||
WriteLPI:=true;
|
||||
WriteLPS:=true;
|
||||
end;
|
||||
//debugln(['TProject.WriteProject WriteLPI=',WriteLPI,' WriteLPS=',WriteLPS,' Modifed=',Modified,' SessionModified=',SessionModified]);
|
||||
|
||||
// backup
|
||||
if WriteLPI and Assigned(fOnFileBackup) then begin
|
||||
@ -4906,65 +4909,75 @@ begin
|
||||
end;
|
||||
|
||||
function TProject.SomethingModified(CheckData, CheckSession: boolean): boolean;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
Result := True;
|
||||
if CheckData then
|
||||
begin
|
||||
if Modified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomethingModified Modified');
|
||||
{$ENDIF}
|
||||
Exit;
|
||||
end;
|
||||
if CompilerOptions.Modified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn(['TProject.SomethingModified CompilerOptions']);
|
||||
{$ENDIF}
|
||||
Exit;
|
||||
end;
|
||||
for i := 0 to UnitCount - 1 do
|
||||
if (Units[i].IsPartOfProject) and Units[i].Modified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomethingModified PartOfProject ',Units[i].Filename);
|
||||
{$ENDIF}
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
if CheckSession then
|
||||
begin
|
||||
if SessionModified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomethingModified SessionModified');
|
||||
{$ENDIF}
|
||||
Exit;
|
||||
end;
|
||||
for i := 0 to UnitCount - 1 do
|
||||
begin
|
||||
if Units[i].SessionModified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomethingModified Session ',Units[i].Filename);
|
||||
{$ENDIF}
|
||||
exit;
|
||||
end;
|
||||
if (not Units[i].IsPartOfProject) and Units[i].Modified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomethingModified Not PartOfProject ',Units[i].Filename);
|
||||
{$ENDIF}
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if CheckData and SomeDataModified then exit;
|
||||
if CheckSession and SessionModified then exit;
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
function TProject.SomeDataModified: boolean;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result:=true;
|
||||
if Modified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomethingModified Modified');
|
||||
{$ENDIF}
|
||||
Exit;
|
||||
end;
|
||||
if CompilerOptions.Modified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn(['TProject.SomethingModified CompilerOptions']);
|
||||
{$ENDIF}
|
||||
Exit;
|
||||
end;
|
||||
for i := 0 to UnitCount - 1 do
|
||||
if (Units[i].IsPartOfProject) and Units[i].Modified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomethingModified PartOfProject ',Units[i].Filename);
|
||||
{$ENDIF}
|
||||
Exit;
|
||||
end;
|
||||
Result:=false;
|
||||
end;
|
||||
|
||||
function TProject.SomeSessionModified: boolean;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result:=true;
|
||||
if SessionModified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomethingModified SessionModified');
|
||||
{$ENDIF}
|
||||
Exit;
|
||||
end;
|
||||
for i := 0 to UnitCount - 1 do
|
||||
begin
|
||||
if Units[i].SessionModified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomethingModified Session ',Units[i].Filename);
|
||||
{$ENDIF}
|
||||
exit;
|
||||
end;
|
||||
if (not Units[i].IsPartOfProject) and Units[i].Modified then
|
||||
begin
|
||||
{$IFDEF VerboseProjectModified}
|
||||
DebugLn('TProject.SomethingModified Not PartOfProject ',Units[i].Filename);
|
||||
{$ENDIF}
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
Result:=false;
|
||||
end;
|
||||
|
||||
procedure TProject.MainSourceFilenameChanged;
|
||||
begin
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user