Skip to content

Commit d6cc61a

Browse files
committed
Form class validation
1 parent 11b60f7 commit d6cc61a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Source/fmx/WrapFmxForms.pas

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
interface
66

77
uses
8-
System.Classes, FMX.Forms,
8+
System.Classes, System.SysUtils, FMX.Forms,
99
PythonEngine, WrapFmxTypes, WrapDelphiClasses, WrapFmxControls;
1010

1111
type
@@ -88,6 +88,8 @@ TPyDelphiScreen = class(TPyDelphiComponent)
8888
property DelphiObject: TScreen read GetDelphiObject write SetDelphiObject;
8989
end;
9090

91+
EInvalidFormClass = class(Exception);
92+
9193
implementation
9294

9395
uses
@@ -169,6 +171,7 @@ TCommonCustomFormClass = class of TCommonCustomForm;
169171
//Delphi class that would have the same name as the Python class.
170172
//This would allow Python to instanciate an existing Delphi form class,
171173
//insted of only using a blank form.
174+
LFormClass := nil;
172175
if (ob_type <> PythonType.TheTypePtr) then begin
173176
LClassName := string(ob_type.tp_name);
174177
LClass := GetClass(LClassName);
@@ -182,6 +185,10 @@ TCommonCustomFormClass = class of TCommonCustomForm;
182185
LFormClass := TCommonCustomFormClass(DelphiObjectClass);
183186
end;
184187

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

0 commit comments

Comments
 (0)