The gintro README contains still a warning from early ARC days that users may have to declare their own destructors if the intent to subclass widgets:
https://github.com/StefanSalewski/gintro#extending-or-sub-classing-widgets
But from a recent test I get the feeling that this is not really necessary any more. With modules tt.nim and t.nim I get:
# module tt.nim
type
O1* = ref object of Rootref
i*: int
when defined(gcDestructors):
proc `=destroy`(o1: var typeof(O1()[])) =
echo "destroy O1 ", typeof(o1)
module t.nim
import tt
type
O2 = ref object of tt.O1
j: int
type
O3 = ref object
o1: tt.O1
type
O4 = object
o1: tt.O1
proc main =
var o1: tt.O1
new o1
echo o1.i
var o2: O2
new o2
echo o2.j
var o3: O3
new o3
new o3.o1
var o4: O4
new o4.o1
main()
salewski@nuc /tmp/hhh $ ./t
0
0
destroy O1 O1:ObjectType
destroy O1 O1:ObjectType
destroy O1 O1:ObjectType
destroy O1 O1:ObjectType
So the destructor is always called for the parent base class, no need for users to declare own destructors any more. Is this new for latest Nim 1.4?