Kaydet (Commit) 9e8b930b authored tarafından Jean-Pierre Ledure's avatar Jean-Pierre Ledure

Dispose() method for all objects

An implicit (Terminate_Class) and an explicit (Dispose) method have been created
to stimulate better memory management.

Change-Id: I240e5117db6bf0d1fcf268e3ddf6d67e0bc1b8eb
üst 552f139d
...@@ -1094,7 +1094,6 @@ Dim i As Integer, iCount As Integer, iAllCount As Integer, ofForm As Variant ...@@ -1094,7 +1094,6 @@ Dim i As Integer, iCount As Integer, iAllCount As Integer, ofForm As Variant
iAllCount = AllForms._Count iAllCount = AllForms._Count
iCount = 0 iCount = 0
If iAllCount > 0 Then If iAllCount > 0 Then
Set ofForm = New Form
For i = 0 To iAllCount - 1 For i = 0 To iAllCount - 1
Set ofForm = Application.AllForms(i) Set ofForm = Application.AllForms(i)
If ofForm.IsLoaded Then iCount = iCount + 1 If ofForm.IsLoaded Then iCount = iCount + 1
...@@ -1108,7 +1107,7 @@ Dim i As Integer, iCount As Integer, iAllCount As Integer, ofForm As Variant ...@@ -1108,7 +1107,7 @@ Dim i As Integer, iCount As Integer, iAllCount As Integer, ofForm As Variant
End If End If
If IsMissing(piCountMax) Then _CountOpenForms = iCount If IsMissing(piCountMax) Then _CountOpenForms = iCount
End Function ' CountOpenForms V1.1.0 End Function ' CountOpenForms V1.1.0
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
......
...@@ -36,7 +36,15 @@ Private Sub Class_Initialize() ...@@ -36,7 +36,15 @@ Private Sub Class_Initialize()
End Sub ' Constructor End Sub ' Constructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
'Private Sub Class_Terminate() Private Sub Class_Terminate()
On Local Error Resume Next
Call Class_Initialize()
End Sub ' Destructor
REM -----------------------------------------------------------------------------------------------------------------------
Public Sub Dispose()
Call Class_Terminate()
End Sub ' Explicit destructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS GET/LET/SET PROPERTIES --- REM --- CLASS GET/LET/SET PROPERTIES ---
......
...@@ -40,8 +40,8 @@ Private Sub Class_Initialize() ...@@ -40,8 +40,8 @@ Private Sub Class_Initialize()
_Shortcut = "" _Shortcut = ""
_Name = "" _Name = ""
Set _FormComponent = Nothing Set _FormComponent = Nothing
_DocEntry = -1 _DocEntry = -1
_DbEntry = -1 _DbEntry = -1
_SubType = "" _SubType = ""
Set ControlModel = Nothing Set ControlModel = Nothing
Set ControlView = Nothing Set ControlView = Nothing
...@@ -51,7 +51,15 @@ Private Sub Class_Initialize() ...@@ -51,7 +51,15 @@ Private Sub Class_Initialize()
End Sub ' Constructor End Sub ' Constructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
'Private Sub Class_Terminate() Private Sub Class_Terminate()
On Local Error Resume Next
Call Class_Initialize()
End Sub ' Destructor
REM -----------------------------------------------------------------------------------------------------------------------
Public Sub Dispose()
Call Class_Terminate()
End Sub ' Explicit destructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS GET/LET/SET PROPERTIES --- REM --- CLASS GET/LET/SET PROPERTIES ---
......
...@@ -40,7 +40,15 @@ Private Sub Class_Initialize() ...@@ -40,7 +40,15 @@ Private Sub Class_Initialize()
End Sub ' Constructor End Sub ' Constructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
'Private Sub Class_Terminate() Private Sub Class_Terminate()
On Local Error Resume Next
Call Class_Initialize()
End Sub ' Destructor
REM -----------------------------------------------------------------------------------------------------------------------
Public Sub Dispose()
Call Class_Terminate()
End Sub ' Explicit destructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS GET/LET/SET PROPERTIES --- REM --- CLASS GET/LET/SET PROPERTIES ---
......
...@@ -48,7 +48,24 @@ Private Sub Class_Initialize() ...@@ -48,7 +48,24 @@ Private Sub Class_Initialize()
End Sub ' Constructor End Sub ' Constructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
'Private Sub Class_Terminate() Private Sub Class_Terminate()
On Local Error Resume Next
If _DbConnect = DBCONNECTANY Then
If Not IsNull(Connection) Then
Connection.close()
Connection.dispose()
Set Connection = Nothing
End If
End If
Call Class_Initialize()
End Sub ' Destructor
REM -----------------------------------------------------------------------------------------------------------------------
Public Sub Dispose()
Call Class_Terminate()
End Sub ' Explicit destructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS GET/LET/SET PROPERTIES --- REM --- CLASS GET/LET/SET PROPERTIES ---
...@@ -64,7 +81,7 @@ REM ---------------------------------------------------------------------------- ...@@ -64,7 +81,7 @@ REM ----------------------------------------------------------------------------
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
Public Function mClose() As Variant Public Function mClose() As Variant
' Close the form ' Close the database
If _ErrorHandler() Then On Local Error Goto Error_Function If _ErrorHandler() Then On Local Error Goto Error_Function
Const cstThisSub = "Database.Close" Const cstThisSub = "Database.Close"
...@@ -74,6 +91,7 @@ Const cstThisSub = "Database.Close" ...@@ -74,6 +91,7 @@ Const cstThisSub = "Database.Close"
Connection.close() Connection.close()
Connection.dispose() Connection.dispose()
Set Connection = Nothing
mClose = True mClose = True
Exit_Function: Exit_Function:
......
...@@ -31,7 +31,15 @@ Private Sub Class_Initialize() ...@@ -31,7 +31,15 @@ Private Sub Class_Initialize()
End Sub ' Constructor End Sub ' Constructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
'Private Sub Class_Terminate() Private Sub Class_Terminate()
On Local Error Resume Next
Call Class_Initialize()
End Sub ' Destructor
REM -----------------------------------------------------------------------------------------------------------------------
Public Sub Dispose()
Call Class_Terminate()
End Sub ' Explicit destructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS GET/LET/SET PROPERTIES --- REM --- CLASS GET/LET/SET PROPERTIES ---
......
...@@ -66,7 +66,15 @@ Private Sub Class_Initialize() ...@@ -66,7 +66,15 @@ Private Sub Class_Initialize()
End Sub ' Constructor End Sub ' Constructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
'Private Sub Class_Terminate() Private Sub Class_Terminate()
On Local Error Resume Next
Call Class_Initialize()
End Sub ' Destructor
REM -----------------------------------------------------------------------------------------------------------------------
Public Sub Dispose()
Call Class_Terminate()
End Sub ' Explicit destructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS GET/LET/SET PROPERTIES --- REM --- CLASS GET/LET/SET PROPERTIES ---
......
...@@ -35,7 +35,15 @@ Private Sub Class_Initialize() ...@@ -35,7 +35,15 @@ Private Sub Class_Initialize()
End Sub ' Constructor End Sub ' Constructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
'Private Sub Class_Terminate() Private Sub Class_Terminate()
On Local Error Resume Next
Call Class_Initialize()
End Sub ' Destructor
REM -----------------------------------------------------------------------------------------------------------------------
Public Sub Dispose()
Call Class_Terminate()
End Sub ' Explicit destructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS GET/LET/SET PROPERTIES --- REM --- CLASS GET/LET/SET PROPERTIES ---
......
...@@ -44,7 +44,15 @@ Private Sub Class_Initialize() ...@@ -44,7 +44,15 @@ Private Sub Class_Initialize()
End Sub ' Constructor End Sub ' Constructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
'Private Sub Class_Terminate() Private Sub Class_Terminate()
On Local Error Resume Next
Call Class_Initialize()
End Sub ' Destructor
REM -----------------------------------------------------------------------------------------------------------------------
Public Sub Dispose()
Call Class_Terminate()
End Sub ' Explicit destructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS GET/LET/SET PROPERTIES --- REM --- CLASS GET/LET/SET PROPERTIES ---
......
...@@ -40,7 +40,15 @@ Private Sub Class_Initialize() ...@@ -40,7 +40,15 @@ Private Sub Class_Initialize()
End Sub ' Constructor End Sub ' Constructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
'Private Sub Class_Terminate() Private Sub Class_Terminate()
On Local Error Resume Next
Call Class_Initialize()
End Sub ' Destructor
REM -----------------------------------------------------------------------------------------------------------------------
Public Sub Dispose()
Call Class_Terminate()
End Sub ' Explicit destructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS GET/LET/SET PROPERTIES --- REM --- CLASS GET/LET/SET PROPERTIES ---
......
...@@ -29,7 +29,15 @@ Private Sub Class_Initialize() ...@@ -29,7 +29,15 @@ Private Sub Class_Initialize()
End Sub ' Constructor End Sub ' Constructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
'Private Sub Class_Terminate() Private Sub Class_Terminate()
On Local Error Resume Next
Call Class_Initialize()
End Sub ' Destructor
REM -----------------------------------------------------------------------------------------------------------------------
Public Sub Dispose()
Call Class_Terminate()
End Sub ' Explicit destructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS GET/LET/SET PROPERTIES --- REM --- CLASS GET/LET/SET PROPERTIES ---
......
...@@ -61,9 +61,8 @@ End Sub ' Constructor ...@@ -61,9 +61,8 @@ End Sub ' Constructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
Private Sub Class_Terminate() Private Sub Class_Terminate()
On Local Error Resume Next
mClose() mClose()
Set Statement = Nothing
Set RowSet = Nothing
End Sub End Sub
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
......
...@@ -38,7 +38,15 @@ Private Sub Class_Initialize() ...@@ -38,7 +38,15 @@ Private Sub Class_Initialize()
End Sub ' Constructor End Sub ' Constructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
'Private Sub Class_Terminate() Private Sub Class_Terminate()
On Local Error Resume Next
Call Class_Initialize()
End Sub ' Destructor
REM -----------------------------------------------------------------------------------------------------------------------
Public Sub Dispose()
Call Class_Terminate()
End Sub ' Explicit destructor
REM ----------------------------------------------------------------------------------------------------------------------- REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS GET/LET/SET PROPERTIES --- REM --- CLASS GET/LET/SET PROPERTIES ---
......
...@@ -8,7 +8,7 @@ REM ============================================================================ ...@@ -8,7 +8,7 @@ REM ============================================================================
Option Explicit Option Explicit
REM Access2Base ----------------------------------------------------- REM Access2Base -----------------------------------------------------
Global Const Access2Base_Version = "1.1.0c" Global Const Access2Base_Version = "1.1.0d"
REM AcCloseSave REM AcCloseSave
REM ----------------------------------------------------------------- REM -----------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment