Use correct parent class when chaining up overridden functions

How `g_type_class_peek ()` was used it didn't return the correct parent
class in most cases.
G_DEFINE_TYPE macro creates a pointer we can use to get the parent
class `n_p_parent_class`.
Because we didn't use the correct parent class the object initialisation
wasn't fully completed for some GtkWidgets.
See https://developer.gnome.org/gobject/stable/chapter-gobject.html#gobject-instantiation
for more information.

This commit makes use of the `n_p_parent_class pointer` created for this
specific use case where ever possible.

Fixes: https://source.puri.sm/Librem5/calls/issues/118
This commit is contained in:
Julian Sparber
2020-02-18 16:01:22 +01:00
parent 06481155fd
commit e911f391c6
24 changed files with 50 additions and 100 deletions

View File

@@ -513,7 +513,6 @@ ugly_hacks (CallsCallDisplay *self)
static void
constructed (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (GTK_TYPE_OVERLAY);
CallsCallDisplay *self = CALLS_CALL_DISPLAY (object);
self->timer = g_timer_new ();
@@ -522,7 +521,7 @@ constructed (GObject *object)
ugly_hacks (self);
parent_class->constructed (object);
G_OBJECT_CLASS (calls_call_display_parent_class)->constructed (object);
}
@@ -565,24 +564,22 @@ calls_call_display_init (CallsCallDisplay *self)
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (GTK_TYPE_OVERLAY);
CallsCallDisplay *self = CALLS_CALL_DISPLAY (object);
stop_timeout (self);
g_clear_object (&self->call);
parent_class->dispose (object);
G_OBJECT_CLASS (calls_call_display_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (GTK_TYPE_OVERLAY);
CallsCallDisplay *self = CALLS_CALL_DISPLAY (object);
g_timer_destroy (self->timer);
parent_class->finalize (object);
G_OBJECT_CLASS (calls_call_display_parent_class)->finalize (object);
}
static void