Skip to content

Commit 45aef24

Browse files
committed
Made PythonEngine.Initialize and PythonEngine.Finalize protected
1 parent 5227506 commit 45aef24

File tree

5 files changed

+101
-115
lines changed

5 files changed

+101
-115
lines changed

Demos/Demo22/Unit1.dfm

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ object Form1: TForm1
1111
Font.Name = 'MS Sans Serif'
1212
Font.Style = []
1313
OldCreateOrder = True
14-
OnClose = FormClose
1514
PixelsPerInch = 96
1615
TextHeight = 13
1716
object Memo1: TMemo

Demos/Demo22/Unit1.pas

-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ TForm1 = class(TForm)
2323
procedure Button1Click(Sender: TObject);
2424
procedure Button2Click(Sender: TObject);
2525
procedure Button3Click(Sender: TObject);
26-
procedure FormClose(Sender: TObject; var Action: TCloseAction);
2726
private
2827
public
2928
end;
@@ -60,9 +59,4 @@ procedure TForm1.Button3Click(Sender: TObject);
6059
end;
6160
end;
6261

63-
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
64-
begin
65-
PythonEngine1.Finalize;
66-
end;
67-
6862
end.

Demos/Demo23/Unit1.dfm

+99-100
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,99 @@
1-
object Form1: TForm1
2-
Left = 387
3-
Top = 223
4-
Caption = 'Demo of Python'
5-
ClientHeight = 336
6-
ClientWidth = 528
7-
Color = clBtnFace
8-
Font.Charset = DEFAULT_CHARSET
9-
Font.Color = clWindowText
10-
Font.Height = -11
11-
Font.Name = 'MS Sans Serif'
12-
Font.Style = []
13-
OldCreateOrder = True
14-
OnClose = FormClose
15-
PixelsPerInch = 96
16-
TextHeight = 13
17-
object Memo1: TMemo
18-
Left = 0
19-
Top = 0
20-
Width = 528
21-
Height = 292
22-
Align = alClient
23-
Font.Charset = DEFAULT_CHARSET
24-
Font.Color = clWindowText
25-
Font.Height = -13
26-
Font.Name = 'Consolas'
27-
Font.Style = []
28-
Lines.Strings = (
29-
'import threading_test'
30-
'import sys'
31-
'try:'
32-
' count = int(sys.argv[1])'
33-
'except:'
34-
' count = 3'
35-
''
36-
'for i in range(count):'
37-
' print ("**** Pass", i)'
38-
' threading_test._test()'
39-
'print ("**** Done.")')
40-
ParentFont = False
41-
ScrollBars = ssBoth
42-
TabOrder = 1
43-
end
44-
object Panel1: TPanel
45-
Left = 0
46-
Top = 292
47-
Width = 528
48-
Height = 44
49-
Align = alBottom
50-
BevelOuter = bvNone
51-
TabOrder = 0
52-
object Button1: TButton
53-
Left = 6
54-
Top = 8
55-
Width = 115
56-
Height = 25
57-
Caption = 'Execute script'
58-
TabOrder = 0
59-
OnClick = Button1Click
60-
end
61-
object Button2: TButton
62-
Left = 168
63-
Top = 8
64-
Width = 91
65-
Height = 25
66-
Caption = 'Load script...'
67-
TabOrder = 1
68-
OnClick = Button2Click
69-
end
70-
object Button3: TButton
71-
Left = 264
72-
Top = 8
73-
Width = 89
74-
Height = 25
75-
Caption = 'Save script...'
76-
TabOrder = 2
77-
OnClick = Button3Click
78-
end
79-
end
80-
object PythonEngine1: TPythonEngine
81-
IO = PythonInputOutput1
82-
Left = 32
83-
end
84-
object OpenDialog1: TOpenDialog
85-
DefaultExt = '*.py'
86-
Filter = 'Python files|*.py|Text files|*.txt|All files|*.*'
87-
Left = 176
88-
end
89-
object SaveDialog1: TSaveDialog
90-
DefaultExt = '*.py'
91-
Filter = 'Python files|*.py|Text files|*.txt|All files|*.*'
92-
Left = 208
93-
end
94-
object PythonInputOutput1: TPythonInputOutput
95-
OnSendData = PythonInputOutput1SendData
96-
UnicodeIO = False
97-
RawOutput = False
98-
Left = 64
99-
end
100-
end
1+
object Form1: TForm1
2+
Left = 387
3+
Top = 223
4+
Caption = 'Demo of Python'
5+
ClientHeight = 336
6+
ClientWidth = 528
7+
Color = clBtnFace
8+
Font.Charset = DEFAULT_CHARSET
9+
Font.Color = clWindowText
10+
Font.Height = -11
11+
Font.Name = 'MS Sans Serif'
12+
Font.Style = []
13+
OldCreateOrder = True
14+
PixelsPerInch = 96
15+
TextHeight = 13
16+
object Memo1: TMemo
17+
Left = 0
18+
Top = 0
19+
Width = 528
20+
Height = 292
21+
Align = alClient
22+
Font.Charset = DEFAULT_CHARSET
23+
Font.Color = clWindowText
24+
Font.Height = -13
25+
Font.Name = 'Consolas'
26+
Font.Style = []
27+
Lines.Strings = (
28+
'import threading_test'
29+
'import sys'
30+
'try:'
31+
' count = int(sys.argv[1])'
32+
'except:'
33+
' count = 3'
34+
''
35+
'for i in range(count):'
36+
' print ("**** Pass", i)'
37+
' threading_test._test()'
38+
'print ("**** Done.")')
39+
ParentFont = False
40+
ScrollBars = ssBoth
41+
TabOrder = 1
42+
end
43+
object Panel1: TPanel
44+
Left = 0
45+
Top = 292
46+
Width = 528
47+
Height = 44
48+
Align = alBottom
49+
BevelOuter = bvNone
50+
TabOrder = 0
51+
object Button1: TButton
52+
Left = 6
53+
Top = 8
54+
Width = 115
55+
Height = 25
56+
Caption = 'Execute script'
57+
TabOrder = 0
58+
OnClick = Button1Click
59+
end
60+
object Button2: TButton
61+
Left = 168
62+
Top = 8
63+
Width = 91
64+
Height = 25
65+
Caption = 'Load script...'
66+
TabOrder = 1
67+
OnClick = Button2Click
68+
end
69+
object Button3: TButton
70+
Left = 264
71+
Top = 8
72+
Width = 89
73+
Height = 25
74+
Caption = 'Save script...'
75+
TabOrder = 2
76+
OnClick = Button3Click
77+
end
78+
end
79+
object PythonEngine1: TPythonEngine
80+
IO = PythonInputOutput1
81+
Left = 32
82+
end
83+
object OpenDialog1: TOpenDialog
84+
DefaultExt = '*.py'
85+
Filter = 'Python files|*.py|Text files|*.txt|All files|*.*'
86+
Left = 176
87+
end
88+
object SaveDialog1: TSaveDialog
89+
DefaultExt = '*.py'
90+
Filter = 'Python files|*.py|Text files|*.txt|All files|*.*'
91+
Left = 208
92+
end
93+
object PythonInputOutput1: TPythonInputOutput
94+
OnSendData = PythonInputOutput1SendData
95+
UnicodeIO = False
96+
RawOutput = False
97+
Left = 64
98+
end
99+
end

Demos/Demo23/Unit1.pas

-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ TForm1 = class(TForm)
2424
procedure Button1Click(Sender: TObject);
2525
procedure Button2Click(Sender: TObject);
2626
procedure Button3Click(Sender: TObject);
27-
procedure FormClose(Sender: TObject; var Action: TCloseAction);
2827
procedure PythonInputOutput1SendData(Sender: TObject;
2928
const Data: AnsiString);
3029
end;
@@ -61,11 +60,6 @@ procedure TForm1.Button3Click(Sender: TObject);
6160
end;
6261
end;
6362

64-
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
65-
begin
66-
PythonEngine1.Finalize;
67-
end;
68-
6963
procedure TForm1.PythonInputOutput1SendData(Sender: TObject;
7064
const Data: AnsiString);
7165
begin

Source/PythonEngine.pas

+2-2
Original file line numberDiff line numberDiff line change
@@ -1774,6 +1774,8 @@ TPythonEngine = class(TPythonInterface)
17741774
FPyDateTime_DateTimeTZType: PPyObject;
17751775

17761776
protected
1777+
procedure Initialize;
1778+
procedure Finalize;
17771779
procedure AfterLoad; override;
17781780
procedure BeforeLoad; override;
17791781
procedure DoOpenDll(const aDllName : string); override;
@@ -1799,8 +1801,6 @@ TPythonEngine = class(TPythonInterface)
17991801
destructor Destroy; override;
18001802

18011803
// Public methods
1802-
procedure Initialize;
1803-
procedure Finalize;
18041804
procedure Lock;
18051805
procedure Unlock;
18061806
procedure SetPythonHome(const PythonHome: UnicodeString);

0 commit comments

Comments
 (0)