lcl: raise an exception if form resource is not found inside Create constructor. For resourceless forms CreateNew constructor must be used.

git-svn-id: trunk@29262 -
This commit is contained in:
paul 2011-01-31 03:39:06 +00:00
parent bfe85e683f
commit 8b2ec0ed64

View File

@ -1870,25 +1870,17 @@ end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TCustomForm Constructor TCustomForm Constructor
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
constructor TCustomForm.Create(AOwner : TComponent); constructor TCustomForm.Create(AOwner: TComponent);
begin begin
//DebugLn('[TCustomForm.Create] A Class=',Classname);
GlobalNameSpace.BeginWrite; GlobalNameSpace.BeginWrite;
try try
CreateNew(AOwner, 1); // this calls BeginFormUpdate, which is ended in AfterConstruction CreateNew(AOwner, 1); // this calls BeginFormUpdate, which is ended in AfterConstruction
//DebugLn('[TCustomForm.Create] B Class=',Classname);
if (ClassType <> TForm) and not (csDesigning in ComponentState) then if (ClassType <> TForm) and not (csDesigning in ComponentState) then
begin begin
Include(FFormState, fsCreating); Include(FFormState, fsCreating);
try try
//DebugLn('[TCustomForm.Create] C Class=',Classname); if not InitResourceComponent(Self, TForm) then
if not InitResourceComponent(Self, TForm) then begin raise EResNotFound.CreateFmt(rsResourceNotFound, [ClassName]);
//DebugLn('[TCustomForm.Create] Resource '''+ClassName+''' not found');
//DebugLn('This is for information purposes only. This is not critical at this time.');
// MG: Ignoring is best at the moment. (Delphi raises an exception.)
end;
//DebugLn('[TCustomForm.Create] D Class=',Classname);
//DebugLn('[TCustomForm.Create] E Class=',Classname);
finally finally
Exclude(FFormState, fsCreating); Exclude(FFormState, fsCreating);
end; end;
@ -1896,7 +1888,6 @@ begin
finally finally
GlobalNameSpace.EndWrite; GlobalNameSpace.EndWrite;
end; end;
//DebugLn('[TCustomForm.Create] END Class=',Classname);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------