Skip to content

Commit c743db8

Browse files
committed
Form class validation
1 parent d6cc61a commit c743db8

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

Source/fmx/WrapFmxForms.pas

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ TPyDelphiScreen = class(TPyDelphiComponent)
8888
property DelphiObject: TScreen read GetDelphiObject write SetDelphiObject;
8989
end;
9090

91-
EInvalidFormClass = class(Exception);
92-
9391
implementation
9492

9593
uses
@@ -167,28 +165,23 @@ TCommonCustomFormClass = class of TCommonCustomForm;
167165
LFormClass: TCommonCustomFormClass;
168166
LClassName: string;
169167
begin
168+
//get de default form class
169+
if DelphiObjectClass.InheritsFrom(TCommonCustomForm) then
170+
LFormClass := TCommonCustomFormClass(DelphiObjectClass);
171+
170172
//if we have a subclass of our Form wrapper, then check if we can find a
171173
//Delphi class that would have the same name as the Python class.
172174
//This would allow Python to instanciate an existing Delphi form class,
173175
//insted of only using a blank form.
174-
LFormClass := nil;
175176
if (ob_type <> PythonType.TheTypePtr) then begin
176177
LClassName := string(ob_type.tp_name);
177178
LClass := GetClass(LClassName);
178179
if not Assigned(LClass) then
179180
LClass := GetClass('T' + LClassName);
180181
if Assigned(LClass) and LClass.InheritsFrom(TCommonCustomForm) then
181182
LFormClass := TCommonCustomFormClass(LClass);
182-
end else begin
183-
//get de default form class
184-
if DelphiObjectClass.InheritsFrom(TCommonCustomForm) then
185-
LFormClass := TCommonCustomFormClass(DelphiObjectClass);
186183
end;
187184

188-
if not Assigned(LFormClass) then
189-
raise EInvalidFormClass.CreateFmt('Type %s is not a valid form class', [
190-
DelphiObjectClass.ClassName]);
191-
192185
//if it's not a design form, so we create it as a non-resourced form,
193186
//using the non-resourced constructor.
194187
//if the Owner is TApplication, then we have to call its CreateForm method,

0 commit comments

Comments
 (0)