ensure


Description:

[ Version ( since = "2.34" ) ]
public void ensure ()

Ensures that the indicated type has been registered with the type system, and its _class_init method has been run.

Typically, calling the type’s `_get_type()` method (or using the corresponding macro) will take care of this. In situations where a type is looked up dynamically, however, you may need to explicitly call `g_type_ensure()` to ensure expected types are registered before the first lookup. This can happen when using custom widgets from a GTK `.ui` file, for example.

Historically, `_get_type()` methods have sometimes been marked as [`G_GNUC_CONST`](macros.html#compiler). This is incorrect, as the first call to a `_get_type()` method has side-effects. These annotations should be removed, as they can cause code to be optimized out in unexpected ways by the compiler.

Parameters:

type

a Type