mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-04 13:43:05 +02:00
ide: use {$R *.res} instead of {$R <projectname>.res} - this simplifies project renaming and simplify resource handling in general (issue #0015985)
git-svn-id: trunk@23976 -
This commit is contained in:
parent
6990c213d3
commit
110e7b7c88
@ -573,7 +573,7 @@ begin
|
|||||||
// update {$R filename} directive
|
// update {$R filename} directive
|
||||||
if CodeToolBoss.FindResourceDirective(CodeBuf, 1, 1,
|
if CodeToolBoss.FindResourceDirective(CodeBuf, 1, 1,
|
||||||
NewCode, NewX, NewY,
|
NewCode, NewX, NewY,
|
||||||
NewTopLine, Filename, false) then
|
NewTopLine, '*.res', false) then
|
||||||
begin
|
begin
|
||||||
// there is a resource directive in the source
|
// there is a resource directive in the source
|
||||||
if not HasSystemResources then
|
if not HasSystemResources then
|
||||||
@ -581,8 +581,7 @@ begin
|
|||||||
if not CodeToolBoss.RemoveDirective(NewCode, NewX, NewY, true) then
|
if not CodeToolBoss.RemoveDirective(NewCode, NewX, NewY, true) then
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
Messages.Add(Format(lisCouldNotRemoveRFromMainSource, ['"', Filename,
|
Messages.Add(Format(lisCouldNotRemoveRFromMainSource, ['"', Filename, '"']));
|
||||||
'"']));
|
|
||||||
debugln(['TProjectResources.UpdateMainSourceFile failed: removing resource directive']);
|
debugln(['TProjectResources.UpdateMainSourceFile failed: removing resource directive']);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -590,7 +589,7 @@ begin
|
|||||||
else
|
else
|
||||||
if HasSystemResources then
|
if HasSystemResources then
|
||||||
begin
|
begin
|
||||||
Directive := '{$R '+Filename+'}';
|
Directive := '{$R *.res}';
|
||||||
if not CodeToolBoss.AddResourceDirective(CodeBuf, Filename, false, Directive) then
|
if not CodeToolBoss.AddResourceDirective(CodeBuf, Filename, false, Directive) then
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
@ -663,9 +662,7 @@ var
|
|||||||
NewX, NewY, NewTopLine: integer;
|
NewX, NewY, NewTopLine: integer;
|
||||||
CodeBuf, NewCode: TCodeBuffer;
|
CodeBuf, NewCode: TCodeBuffer;
|
||||||
|
|
||||||
Directive,
|
oldLrsFileName, newLrsFileName: String;
|
||||||
oldResFileName, oldLrsFileName,
|
|
||||||
newResFilename, newLrsFileName: String;
|
|
||||||
begin
|
begin
|
||||||
//DebugLn(['TProjectResources.RenameDirectives CurFileName="',CurFileName,'" NewFileName="',NewFileName,'"']);
|
//DebugLn(['TProjectResources.RenameDirectives CurFileName="',CurFileName,'" NewFileName="',NewFileName,'"']);
|
||||||
Result := True;
|
Result := True;
|
||||||
@ -678,10 +675,8 @@ begin
|
|||||||
LastLrsFileName := lrsFileName;
|
LastLrsFileName := lrsFileName;
|
||||||
try
|
try
|
||||||
SetFileNames(CurFileName, '');
|
SetFileNames(CurFileName, '');
|
||||||
oldResFilename := ExtractFileName(resFileName);
|
|
||||||
oldLrsFileName := ExtractFileName(lrsFileName);
|
oldLrsFileName := ExtractFileName(lrsFileName);
|
||||||
SetFileNames(NewFileName, '');
|
SetFileNames(NewFileName, '');
|
||||||
newResFilename := ExtractFileName(resFileName);
|
|
||||||
newLrsFileName := ExtractFileName(lrsFileName);
|
newLrsFileName := ExtractFileName(lrsFileName);
|
||||||
|
|
||||||
// update resources (FLazarusResources, FSystemResources, ...)
|
// update resources (FLazarusResources, FSystemResources, ...)
|
||||||
@ -691,27 +686,6 @@ begin
|
|||||||
// update codebuffers of new .lrs and .res files
|
// update codebuffers of new .lrs and .res files
|
||||||
UpdateCodeBuffers;
|
UpdateCodeBuffers;
|
||||||
|
|
||||||
// update {$R filename} directive
|
|
||||||
if CodeToolBoss.FindResourceDirective(CodeBuf, 1, 1,
|
|
||||||
NewCode, NewX, NewY,
|
|
||||||
NewTopLine, oldResFileName, false) then
|
|
||||||
begin
|
|
||||||
// there is a resource directive in the source
|
|
||||||
if not CodeToolBoss.RemoveDirective(NewCode, NewX, NewY, true) then
|
|
||||||
begin
|
|
||||||
Result := False;
|
|
||||||
debugln(['TProjectResources.RenameDirectives failed: removing resource directive']);
|
|
||||||
Messages.Add('Could not remove "{$R '+ oldResFileName +'"} from main source!');
|
|
||||||
end;
|
|
||||||
Directive := '{$R '+ newResFileName +'}';
|
|
||||||
if not CodeToolBoss.AddResourceDirective(CodeBuf, newResFileName, false, Directive) then
|
|
||||||
begin
|
|
||||||
Result := False;
|
|
||||||
debugln(['TProjectResources.RenameDirectives failed: adding resource directive']);
|
|
||||||
Messages.Add('Could not add "{$R '+ newResFileName +'"} to main source!');
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// update {$I filename} directive
|
// update {$I filename} directive
|
||||||
if CodeToolBoss.FindIncludeDirective(CodeBuf, 1, 1,
|
if CodeToolBoss.FindIncludeDirective(CodeBuf, 1, 1,
|
||||||
NewCode, NewX, NewY,
|
NewCode, NewX, NewY,
|
||||||
|
Loading…
Reference in New Issue
Block a user