Subject "Session is undefined" error when destroying a session
Author
I'm running up against an order-of-operations bug when destroying a session.

I created a connection using TIB_Connection.CreateForSession, and I've been using its DefaultTransaction property.  I've verified that this gets set up with the proper IB_Session property.

When I free the session, it calls CleanupSessionChildren, which sets the IB_Session property to nil on various components, including the transaction.  Then it calls inherited Destroy, which leads to the following stack trace, ending in an error when the transaction's session is found to be set to nil:

:76bec41f KERNELBASE.RaiseException + 0x58
IB_Components.TIB_Component.CheckSession(True)
IB_Components.TIB_SchemaCache.FreeResources
IB_Components.TIB_SchemaCache.Destroy
System.TObject.Free
IB_Components.TIB_Connection.Destroy
Classes.TComponent.DestroyComponents
Classes.TComponent.Destroy
IB_Session.TIB_SessionBase.Destroy
IB_Components.TIB_Session.Destroy

Mason