Hello, I wanted to check that the destructor is always called, even when an exception is thrown during the construction of the object.
I've coded this up in Genie and when the object can't be created, because the resource (an empty file in this case) isn't available, an exception is thrown. I'm assuming Vala has already created the object reference count, so when it goes out of scope of the 'try' block the destructor is always called, even if the object has not been fully initialised by the constructor. The Vala tutorial states the Vala's "memory management is based on reference counting instead of tracing garbage collection, destructors are deterministic and can be used to implement the RAII pattern for resource management". I know anything that calls the C exit() function, such as Process.exit(0), will break the program immediately and so stop the destructor being called. I wondered if there were any other circumstances when the destructor wouldn't be called so I can be sure I need to code the freeing of the resources only in the destructor. Thanks, Al _______________________________________________ vala-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/vala-list
