From 77e0434dd96d6c07f401667627c33dae108e59f0 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 1 Apr 2013 13:01:17 +0000 Subject: [PATCH] IDE: fixed crash on GetUnitResourceFileformat when unit not yet loaded git-svn-id: trunk@40683 - --- ide/project.pp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ide/project.pp b/ide/project.pp index 8cfcad28cd..4ce7c18c33 100644 --- a/ide/project.pp +++ b/ide/project.pp @@ -2409,19 +2409,24 @@ var begin if not assigned(FUnitResourceFileformat) then begin - ResourceFormats := GetUnitResourcefileFormats; - for i := 0 to high(ResourceFormats) do + if Source=nil then + Source:=CodeToolBoss.LoadFile(Filename,true,false); + if Source<>nil then begin - if ResourceFormats[i].FindResourceDirective(Source) then + ResourceFormats := GetUnitResourcefileFormats; + for i := 0 to high(ResourceFormats) do begin - FUnitResourceFileformat:=ResourceFormats[i]; - result := FUnitResourceFileformat; - Exit; + if ResourceFormats[i].FindResourceDirective(Source) then + begin + FUnitResourceFileformat:=ResourceFormats[i]; + Result := FUnitResourceFileformat; + Exit; + end; end; end; FUnitResourceFileformat := TLFMUnitResourcefileFormat; end; - result := FUnitResourceFileformat; + Result := FUnitResourceFileformat; end; procedure TUnitInfo.SetAutoReferenceSourceDir(const AValue: boolean);