mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-21 10:59:36 +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
|
uses
|
||||||
Classes, SysUtils, FileUtil, Process, LCLProc, Controls, Forms,
|
Classes, SysUtils, FileUtil, Process, LCLProc, Controls, Forms,
|
||||||
CodeToolManager, LazConf, Laz_XMLCfg, LResources, resource, groupiconresource,
|
CodeToolManager, CodeCache, LazConf, Laz_XMLCfg, LResources, resource,
|
||||||
ProjectIntf, ProjectResourcesIntf;
|
DialogProcs, groupiconresource, ProjectIntf, ProjectResourcesIntf;
|
||||||
|
|
||||||
type
|
type
|
||||||
TIconData = array of byte;
|
TIconData = array of byte;
|
||||||
@ -127,7 +127,8 @@ begin
|
|||||||
|
|
||||||
SetFileNames(MainFilename);
|
SetFileNames(MainFilename);
|
||||||
if FilenameIsAbsolute(FIcoFileName) then
|
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
|
{ to create an lrs with icon we can use this but there is no reason anymore
|
||||||
if AResources.ResourceType <> rtRes then
|
if AResources.ResourceType <> rtRes then
|
||||||
@ -182,19 +183,20 @@ end;
|
|||||||
|
|
||||||
function TProjectIcon.CreateIconFile: Boolean;
|
function TProjectIcon.CreateIconFile: Boolean;
|
||||||
var
|
var
|
||||||
FileStream, AStream: TStream;
|
AStream: TStream;
|
||||||
|
Code: TCodeBuffer;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
AStream := GetStream;
|
AStream := GetStream;
|
||||||
FileStream := nil;
|
if AStream=nil then exit;
|
||||||
try
|
try
|
||||||
FileStream := TFileStream.Create(UTF8ToSys(FicoFileName), fmCreate);
|
Code:=CodeToolBoss.CreateFile(FicoFileName);
|
||||||
FileStream.CopyFrom(AStream, AStream.Size);
|
if Code=nil then exit;
|
||||||
Result := True;
|
Code.LoadFromStream(AStream);
|
||||||
|
Result:=SaveCodeBuffer(Code) in [mrOk,mrIgnore];
|
||||||
finally
|
finally
|
||||||
FileStream.Free;
|
AStream.Free;
|
||||||
end;
|
end;
|
||||||
AStream.Free;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{-----------------------------------------------------------------------------
|
{-----------------------------------------------------------------------------
|
||||||
|
@ -369,6 +369,7 @@ function TProjectResources.Update: Boolean;
|
|||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
|
Result:=true;
|
||||||
Clear;
|
Clear;
|
||||||
for i := 0 to FResources.Count - 1 do
|
for i := 0 to FResources.Count - 1 do
|
||||||
begin
|
begin
|
||||||
@ -483,7 +484,7 @@ begin
|
|||||||
Result := False;
|
Result := False;
|
||||||
|
|
||||||
if (MainFileName = '') then
|
if (MainFileName = '') then
|
||||||
Exit;
|
Exit(true);
|
||||||
|
|
||||||
// remember old codebuffer filenames
|
// remember old codebuffer filenames
|
||||||
LastResFilename := resFileName;
|
LastResFilename := resFileName;
|
||||||
|
Loading…
Reference in New Issue
Block a user