@@ -9,10 +9,18 @@ Attribute VB_PredeclaredId = True
99Attribute VB_Exposed = False
1010
1111
12- Private Type TThis
12+ Private Type TThisSingleton
1313 stack as stdArray
1414 RaiseClient As Object 'Allow Raise through a custom userform. Userform should expose a Raise(sMessage, Criticality, Title, StackTrace) method.
1515End Type
16+ Private Type TThisInstance
17+ xx as string
18+ End Type
19+
20+ Private Type TThis
21+ Singleton As TThisSingleton
22+ Instance As TThisInstance
23+ End Type
1624Private This as TThis
1725
1826'New Syntax:
@@ -24,15 +32,21 @@ Private This as TThis
2432' End With
2533' end sub
2634Public Function getSentry (ByVal sSubName As String , ParamArray args() as variant ) As Object 'stdSentry
27- If TypeName(stdSentry) = "stdSentry" Then
28- Dim vArgs As Variant : vArgs = args
29- Set getSentry = stdSentry.Create( _
30- stdCallback.CreateFromObjectMethod(stdError, "addStack" ).Bind(sSubName, vArgs), _
31- stdCallback.CreateFromObjectMethod(stdError, "popStack" ) _
32- ).Run()
33- End If
35+ Call addStack (sSubName, args)
36+
37+ 'A fresh instance acts as a stack popper.
38+ set getSentry = New stdError
3439End Function
3540
41+ Public Sub Class_Terminate ()
42+ 'Only do this on fresh instances, not the singleton.
43+ if Me is stdError then Exit Sub
44+
45+ 'On class termination, pop the stack.
46+ On Error Resume Next
47+ Call PopStack
48+ End Sub
49+
3650Public Property Get stack() As stdArray
3751 'Return the stack object, creating it if it doesn't exist.
3852 If this.stack Is Nothing Then
0 commit comments