IDE: fixed writing project ico, verbosity for failed resource generate

git-svn-id: trunk@37948 -
This commit is contained in:
mattias 2012-07-15 10:13:43 +00:00
parent 86e27ff8a7
commit 8d2d0b8f96
3 changed files with 28 additions and 22 deletions

View File

@ -12301,7 +12301,7 @@ begin
if not Project1.ProjResources.Regenerate(Project1.MainFilename, False, True, TargetExeDirectory) if not Project1.ProjResources.Regenerate(Project1.MainFilename, False, True, TargetExeDirectory)
then begin then begin
debugln(['TMainIDE.DoBuildProject Project1.ProjResources.Regenerate failed']); debugln(['TMainIDE.DoBuildProject ProjResources.Regenerate failed']);
exit; exit;
end; end;
@ -12314,7 +12314,7 @@ begin
Project1.ProjectDirectory,lisExecutingCommandBefore); Project1.ProjectDirectory,lisExecutingCommandBefore);
if Result<>mrOk then if Result<>mrOk then
begin begin
debugln(['TMainIDE.DoBuildProject Project1.CompilerOptions.ExecuteBefore.Execute failed']); debugln(['TMainIDE.DoBuildProject CompilerOptions.ExecuteBefore.Execute failed']);
CompileProgress.Ready(lisInfoBuildError); CompileProgress.Ready(lisInfoBuildError);
exit; exit;
end; end;

View File

@ -127,20 +127,10 @@ begin
SetFileNames(MainFilename); SetFileNames(MainFilename);
if FilenameIsAbsolute(FIcoFileName) then if FilenameIsAbsolute(FIcoFileName) then
if not CreateIconFile then if not CreateIconFile then begin
debugln(['TProjectIcon.UpdateResources CreateIconFile "'+FIcoFileName+'" failed']);
exit(false); exit(false);
{ to create an lrs with icon we can use this but there is no reason anymore
if AResources.ResourceType <> rtRes then
begin
AResource := GetStream;
try
AResources.AddLazarusResource(AResource, 'MAINICON', 'ICO');
finally
AResource.Free;
end; end;
end;
}
AName := TResourceDesc.Create('MAINICON'); AName := TResourceDesc.Create('MAINICON');
ARes := TGroupIconResource.Create(nil, AName); //type is always RT_GROUP_ICON ARes := TGroupIconResource.Create(nil, AName); //type is always RT_GROUP_ICON
@ -153,7 +143,7 @@ begin
ItemStream:=ARes.ItemData; ItemStream:=ARes.ItemData;
except except
on E: Exception do begin on E: Exception do begin
DebugLn(['TProjectIcon.UpdateResources bug in fcl: ',E.Message]); DebugLn(['TProjectIcon.UpdateResources ignoring bug in fcl: ',E.Message]);
end; end;
end; end;
if ItemStream<>nil then if ItemStream<>nil then
@ -188,13 +178,19 @@ begin
Result := False; Result := False;
if IsEmpty then exit; if IsEmpty then exit;
try try
fs:=TFileStreamUTF8.Create(FIcoFileName,fmCreate or fmOpenReadWrite); if FileExistsUTF8(FIcoFileName) then
fs:=TFileStreamUTF8.Create(FIcoFileName,fmOpenWrite)
else
fs:=TFileStreamUTF8.Create(FIcoFileName,fmCreate);
try try
fs.Write(FData[0],length(FData)); fs.Write(FData[0],length(FData));
Result:=true;
finally finally
fs.Free; fs.Free;
end; end;
except except
on E: Exception do
debugln(['TProjectIcon.CreateIconFile "'+FIcoFileName+'": '+E.Message]);
end; end;
end; end;

View File

@ -368,14 +368,18 @@ end;
function TProjectResources.Update: Boolean; function TProjectResources.Update: Boolean;
var var
i: integer; i: integer;
Res: TAbstractProjectResource;
begin begin
Result:=true; Result:=true;
Clear; Clear;
for i := 0 to FResources.Count - 1 do for i := 0 to FResources.Count - 1 do
begin begin
Result := TAbstractProjectResource(FResources[i]).UpdateResources(Self, resFileName); Res:=TAbstractProjectResource(FResources[i]);
if not Result then Result := Res.UpdateResources(Self, resFileName);
if not Result then begin
debugln(['TProjectResources.Update UpdateResources of ',DbgSName(Res),' failed']);
Exit; Exit;
end;
end; end;
end; end;
@ -495,16 +499,22 @@ begin
try try
// update resources (FLazarusResources, FSystemResources, ...) // update resources (FLazarusResources, FSystemResources, ...)
if not Update then if not Update then begin
debugln(['TProjectResources.Regenerate Update failed']);
Exit; Exit;
end;
// create codebuffers of new .lrs and .rc files // create codebuffers of new .lrs and .rc files
UpdateCodeBuffers; UpdateCodeBuffers;
// update .lpr file (old and new include files exist, so parsing should work without errors) // update .lpr file (old and new include files exist, so parsing should work without errors)
if UpdateSource and not UpdateMainSourceFile(MainFileName) then if UpdateSource and not UpdateMainSourceFile(MainFileName) then begin
Exit; debugln(['TProjectResources.Regenerate UpdateMainSourceFile failed']);
exit;
end;
if PerformSave and not Save(SaveToTestDir) then if PerformSave and not Save(SaveToTestDir) then begin
debugln(['TProjectResources.Regenerate Save failed']);
Exit; Exit;
end;
finally finally
DeleteLastCodeBuffers; DeleteLastCodeBuffers;
end; end;