Skip to content

sourceview: Initialize assistants and snippets later

When _gtk_source_view_snippets_init() is called, it retrieves the buffer from the view in order to initialize support for snippets. This function is called in gtk_source_view_init().

The base class, GtkTextView, figures there's no GtkTextBuffer and creates one. It does so by executing the GtkTextViewClass.create_buffer() vfunc.

The problem here is that, when subclasses of GtkSourceView are involved, gtk_source_view_init() too early; even if the subclass overrides the GtkTextViewClass.create_buffer() vfunc the type system won't know have that information yet - since we're still in the instance init step - and will call into GtkSourceView's vfunc override.

Be a bit more subclass-friendly by delaying the initalization of snippets to gtk_source_view_constructed(); constructed is late enough for the type system to call into the right vfunc, but early enough to not make a significant difference on the initialization of GtkSourceView.

Edited by Georges Basile Stavracas Neto

Merge request reports