codetools: fixed boss.loadfile to not load when autorevert is disabled

git-svn-id: trunk@16808 -
This commit is contained in:
mattias 2008-09-30 08:41:35 +00:00
parent 4dea886e4b
commit f30a307736
3 changed files with 21 additions and 15 deletions

View File

@ -922,12 +922,11 @@ end;
procedure TCodeBuffer.SetIsDeleted(const NewValue: boolean);
begin
if FIsDeleted=NewValue then exit;
//debugln(['TCodeBuffer.SetIsDeleted ',Filename,' ',NewValue]);
debugln(['TCodeBuffer.SetIsDeleted ',Filename,' ',NewValue]);
FIsDeleted:=NewValue;
if FIsDeleted then begin
Clear;
FIsDeleted:=true;
FLoadDateValid:=false;
//DebugLn(['TCodeBuffer.SetIsDeleted ',Filename,' ',FileNeedsUpdate]);
end;
end;
@ -975,17 +974,17 @@ begin
end;
function TCodeBuffer.FileNeedsUpdate: boolean;
// file needs update, if file is not modified and file on disk has changed
// file needs update (to be loaded), if file is not modified and file on disk has changed
begin
if Modified then exit(false);
if LoadDateValid then
Result:=(not Modified) and (FFileChangeStep=ChangeStep)
and (FileDateOnDisk<>LoadDate)
Result:=(FFileChangeStep=ChangeStep) and (FileDateOnDisk<>LoadDate)
else
Result:=true;
end;
function TCodeBuffer.FileOnDiskNeedsUpdate: boolean;
// file on disk needs update, if memory is modified or file does not exist
// file on disk needs update (to be saved), if memory is modified or file does not exist
begin
if LoadDateValid then
Result:=Modified or (FFileChangeStep<>ChangeStep)

View File

@ -959,12 +959,19 @@ begin
{$IFDEF CTDEBUG}
DebugLn('>>>>>> [TCodeToolManager.LoadFile] ',ExpandedFilename,' Update=',dbgs(UpdateFromDisk),' Revert=',dbgs(Revert));
{$ENDIF}
if (not UpdateFromDisk) and (not Revert) then begin
Result:=SourceCache.FindFile(ExpandedFilename);
if (Result<>nil) and (not Result.IsDeleted) then exit;
end;
Result:=SourceCache.LoadFile(ExpandedFilename);
if Result<>nil then begin
if Revert then
Result.Revert
else if UpdateFromDisk then
else if UpdateFromDisk and Result.AutoRevertFromDisk
and Result.FileNeedsUpdate then begin
//debugln(['TCodeToolManager.LoadFile ',ExpandedFilename,' AutoRevert=',Result.AutoRevertFromDisk,' Modified=',Result.Modified,' NeedLoad=',Result.FileNeedsUpdate]);
Result.Reload;
end;
end;
end;

View File

@ -7289,6 +7289,14 @@ begin
Result:=mrOk;
end;
// close form soft (keep it if used by another component)
CloseUnitComponent(ActiveUnitInfo,[]);
// close source editor
SourceNoteBook.CloseFile(PageIndex);
MainIDEBar.itmFileClose.Enabled:=SourceNoteBook.Notebook<>nil;
MainIDEBar.itmFileCloseAll.Enabled:=MainIDEBar.itmFileClose.Enabled;
// free sources
if (ActiveUnitInfo.Source<>nil) then begin
if (Project1.MainUnitInfo=ActiveUnitInfo)
@ -7299,14 +7307,6 @@ begin
ActiveUnitInfo.Source.IsDeleted:=true;
end;
// close form soft (keep it if used by another component)
CloseUnitComponent(ActiveUnitInfo,[]);
// close source editor
SourceNoteBook.CloseFile(PageIndex);
MainIDEBar.itmFileClose.Enabled:=SourceNoteBook.Notebook<>nil;
MainIDEBar.itmFileCloseAll.Enabled:=MainIDEBar.itmFileClose.Enabled;
// close file in project
Project1.CloseEditorIndex(ActiveUnitInfo.EditorIndex);
ActiveUnitInfo.Loaded:=false;