55interface
66
77uses
8- System.Classes, FMX.Forms,
8+ System.Classes, System.SysUtils, FMX.Forms,
99 PythonEngine, WrapFmxTypes, WrapDelphiClasses, WrapFmxControls;
1010
1111type
@@ -88,6 +88,8 @@ TPyDelphiScreen = class(TPyDelphiComponent)
8888 property DelphiObject: TScreen read GetDelphiObject write SetDelphiObject;
8989 end ;
9090
91+ EInvalidFormClass = class (Exception);
92+
9193implementation
9294
9395uses
@@ -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