5
5
interface
6
6
7
7
uses
8
- System.Classes, FMX.Forms,
8
+ System.Classes, System.SysUtils, FMX.Forms,
9
9
PythonEngine, WrapFmxTypes, WrapDelphiClasses, WrapFmxControls;
10
10
11
11
type
@@ -88,6 +88,8 @@ TPyDelphiScreen = class(TPyDelphiComponent)
88
88
property DelphiObject: TScreen read GetDelphiObject write SetDelphiObject;
89
89
end ;
90
90
91
+ EInvalidFormClass = class (Exception);
92
+
91
93
implementation
92
94
93
95
uses
@@ -165,6 +167,11 @@ TCommonCustomFormClass = class of TCommonCustomForm;
165
167
LFormClass: TCommonCustomFormClass;
166
168
LClassName: string;
167
169
begin
170
+ LFormClass := nil ;
171
+ // get de default form class
172
+ if DelphiObjectClass.InheritsFrom(TCommonCustomForm) then
173
+ LFormClass := TCommonCustomFormClass(DelphiObjectClass);
174
+
168
175
// if we have a subclass of our Form wrapper, then check if we can find a
169
176
// Delphi class that would have the same name as the Python class.
170
177
// This would allow Python to instanciate an existing Delphi form class,
@@ -176,12 +183,12 @@ TCommonCustomFormClass = class of TCommonCustomForm;
176
183
LClass := GetClass(' T' + LClassName);
177
184
if Assigned(LClass) and LClass.InheritsFrom(TCommonCustomForm) then
178
185
LFormClass := TCommonCustomFormClass(LClass);
179
- end else begin
180
- // get de default form class
181
- if DelphiObjectClass.InheritsFrom(TCommonCustomForm) then
182
- LFormClass := TCommonCustomFormClass(DelphiObjectClass);
183
186
end ;
184
187
188
+ if not Assigned(LFormClass) then
189
+ raise EInvalidFormClass.CreateFmt(' Type %s is not a valid form class' , [
190
+ DelphiObjectClass.ClassName]);
191
+
185
192
// if it's not a design form, so we create it as a non-resourced form,
186
193
// using the non-resourced constructor.
187
194
// if the Owner is TApplication, then we have to call its CreateForm method,
0 commit comments