Initable

gio.initable.Initable is implemented by objects that can fail during initialization. If an object implements this interface then it must be initialized as the first thing after construction, either via gio.initable.Initable.init_ or gio.async_initable.AsyncInitable.initAsync (the latter is only available if it also implements gio.async_initable.AsyncInitable).

If the object is not initialized, or initialization returns with an error, then all operations on the object except [gobject.object.ObjectG.ref_] and [gobject.object.ObjectG.unref] are considered to be invalid, and have undefined behaviour. They will often fail with func@GLib.critical or func@GLib.warning, but this must not be relied on.

Users of objects implementing this are not intended to use the interface method directly, instead it will be used automatically in various ways. For C applications you generally just call gio.initable.Initable.new_ directly, or indirectly via a foo_thing_new() wrapper. This will call gio.initable.Initable.init_ under the cover, returning NULL and setting a glib.error.ErrorG on failure (at which point the instance is unreferenced).

For bindings in languages where the native constructor supports exceptions the binding could check for objects implementing gio.initable.Initable during normal construction and automatically initialize them, throwing an exception on failure.

Members

Functions

init_
bool init_(gio.cancellable.Cancellable cancellable)

Initializes the object implementing the interface.