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

@@ -477,7 +477,6 @@ set_property (GObject *object,
static void
constructed (GObject *object)
{
GObjectClass *obj_class = g_type_class_peek (G_TYPE_OBJECT);
CallsCallRecordRow *self = CALLS_CALL_RECORD_ROW (object);
gboolean inbound;
GDateTime *answered;
@@ -497,7 +496,7 @@ constructed (GObject *object)
contact_name_cb (self);
request_contact_avatar (self);
obj_class->constructed (object);
G_OBJECT_CLASS (calls_call_record_row_parent_class)->constructed (object);
}
@@ -524,7 +523,6 @@ get_property (GObject *object,
static void
dispose (GObject *object)
{
GObjectClass *obj_class = g_type_class_peek (G_TYPE_OBJECT);
CallsCallRecordRow *self = CALLS_CALL_RECORD_ROW (object);
g_clear_object (&self->new_call);
@@ -537,7 +535,7 @@ dispose (GObject *object)
calls_clear_signal (self->record, &self->end_notify_handler_id);
g_clear_object (&self->record);
obj_class->dispose (object);
G_OBJECT_CLASS (calls_call_record_row_parent_class)->dispose (object);
}