mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 18:03:47 +02:00
IDE: save project icon: save only once and catch write errors
git-svn-id: trunk@35814 -
This commit is contained in:
parent
d9162800f5
commit
9913f6cb48
@ -35,8 +35,8 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Process, LCLProc, Controls, Forms,
|
||||
CodeToolManager, LazConf, Laz_XMLCfg, LResources, resource, groupiconresource,
|
||||
ProjectIntf, ProjectResourcesIntf;
|
||||
CodeToolManager, CodeCache, LazConf, Laz_XMLCfg, LResources, resource,
|
||||
DialogProcs, groupiconresource, ProjectIntf, ProjectResourcesIntf;
|
||||
|
||||
type
|
||||
TIconData = array of byte;
|
||||
@ -127,7 +127,8 @@ begin
|
||||
|
||||
SetFileNames(MainFilename);
|
||||
if FilenameIsAbsolute(FIcoFileName) then
|
||||
CreateIconFile;
|
||||
if not CreateIconFile then
|
||||
exit(false);
|
||||
|
||||
{ to create an lrs with icon we can use this but there is no reason anymore
|
||||
if AResources.ResourceType <> rtRes then
|
||||
@ -182,19 +183,20 @@ end;
|
||||
|
||||
function TProjectIcon.CreateIconFile: Boolean;
|
||||
var
|
||||
FileStream, AStream: TStream;
|
||||
AStream: TStream;
|
||||
Code: TCodeBuffer;
|
||||
begin
|
||||
Result := False;
|
||||
AStream := GetStream;
|
||||
FileStream := nil;
|
||||
if AStream=nil then exit;
|
||||
try
|
||||
FileStream := TFileStream.Create(UTF8ToSys(FicoFileName), fmCreate);
|
||||
FileStream.CopyFrom(AStream, AStream.Size);
|
||||
Result := True;
|
||||
Code:=CodeToolBoss.CreateFile(FicoFileName);
|
||||
if Code=nil then exit;
|
||||
Code.LoadFromStream(AStream);
|
||||
Result:=SaveCodeBuffer(Code) in [mrOk,mrIgnore];
|
||||
finally
|
||||
FileStream.Free;
|
||||
AStream.Free;
|
||||
end;
|
||||
AStream.Free;
|
||||
end;
|
||||
|
||||
{-----------------------------------------------------------------------------
|
||||
|
@ -369,6 +369,7 @@ function TProjectResources.Update: Boolean;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
Result:=true;
|
||||
Clear;
|
||||
for i := 0 to FResources.Count - 1 do
|
||||
begin
|
||||
@ -483,7 +484,7 @@ begin
|
||||
Result := False;
|
||||
|
||||
if (MainFileName = '') then
|
||||
Exit;
|
||||
Exit(true);
|
||||
|
||||
// remember old codebuffer filenames
|
||||
LastResFilename := resFileName;
|
||||
|
Loading…
Reference in New Issue
Block a user