Unverified Commit e911f391 authored by Julian Sparber's avatar Julian Sparber
Browse files

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: Librem5/calls#118
parent 06481155
......@@ -204,7 +204,6 @@ set_property (GObject *object,
static void
constructed (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsDummyCall *self = CALLS_DUMMY_CALL (object);
if (self->inbound)
......@@ -217,7 +216,7 @@ constructed (GObject *object)
g_timeout_add_seconds (1, (GSourceFunc)outbound_timeout_cb, self);
}
parent_class->constructed (object);
G_OBJECT_CLASS (calls_dummy_call_parent_class)->constructed (object);
}
......@@ -244,12 +243,11 @@ get_property (GObject *object,
static void
finalize (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsDummyCall *self = CALLS_DUMMY_CALL (object);
g_free (self->number);
parent_class->finalize (object);
G_OBJECT_CLASS (calls_dummy_call_parent_class)->finalize (object);
}
......
......@@ -217,24 +217,22 @@ set_property (GObject *object,
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsDummyOrigin *self = CALLS_DUMMY_ORIGIN (object);
remove_calls (self, NULL);
parent_class->dispose (object);
G_OBJECT_CLASS (calls_dummy_origin_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsDummyOrigin *self = CALLS_DUMMY_ORIGIN (object);
g_string_free (self->name, TRUE);
parent_class->finalize (object);
G_OBJECT_CLASS (calls_dummy_origin_parent_class)->finalize (object);
}
......
......@@ -102,7 +102,6 @@ usr1_handler (CallsDummyProvider *self)
static void
constructed (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsDummyProvider *self = CALLS_DUMMY_PROVIDER (object);
calls_dummy_provider_add_origin (self, "Dummy origin");
......@@ -111,7 +110,7 @@ constructed (GObject *object)
(GSourceFunc)usr1_handler,
self);
parent_class->constructed (object);
G_OBJECT_CLASS (calls_dummy_provider_parent_class)->constructed (object);
}
......@@ -136,13 +135,12 @@ get_property (GObject *object,
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsDummyProvider *self = CALLS_DUMMY_PROVIDER (object);
g_list_free_full (self->origins, g_object_unref);
self->origins = NULL;
parent_class->dispose (object);
G_OBJECT_CLASS (calls_dummy_provider_parent_class)->dispose (object);
}
......
......@@ -311,7 +311,6 @@ set_property (GObject *object,
static void
constructed (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsMMCall *self = CALLS_MM_CALL (object);
MmGdbusCall *gdbus_call = MM_GDBUS_CALL (self->mm_call);
MMCallState state;
......@@ -336,7 +335,7 @@ constructed (GObject *object)
start_call (CALLS_CALL (self));
}
parent_class->constructed (object);
G_OBJECT_CLASS (calls_mm_call_parent_class)->constructed (object);
}
......@@ -365,25 +364,23 @@ get_property (GObject *object,
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsMMCall *self = CALLS_MM_CALL (object);
g_clear_object (&self->mm_call);
parent_class->dispose (object);
G_OBJECT_CLASS (calls_mm_call_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsMMCall *self = CALLS_MM_CALL (object);
g_free (self->disconnect_reason);
g_string_free (self->number, TRUE);
parent_class->finalize (object);
G_OBJECT_CLASS (calls_mm_call_parent_class)->finalize (object);
}
......
......@@ -446,7 +446,6 @@ modem_get_name (MMModem *modem)
static void
constructed (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsMMOrigin *self = CALLS_MM_ORIGIN (object);
MmGdbusModemVoice *gdbus_voice;
......@@ -466,33 +465,31 @@ constructed (GObject *object)
NULL,
(GAsyncReadyCallback) list_calls_cb,
self);
parent_class->constructed (object);
G_OBJECT_CLASS (calls_mm_origin_parent_class)->constructed (object);
}
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsMMOrigin *self = CALLS_MM_ORIGIN (object);
remove_calls (self, NULL);
g_clear_object (&self->mm_obj);
parent_class->dispose (object);
G_OBJECT_CLASS (calls_mm_origin_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsMMOrigin *self = CALLS_MM_ORIGIN (object);
g_hash_table_unref (self->calls);
g_free (self->name);
parent_class->finalize (object);
G_OBJECT_CLASS (calls_mm_origin_parent_class)->finalize (object);
}
......
......@@ -357,7 +357,6 @@ mm_vanished_cb (GDBusConnection *connection,
static void
constructed (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsMMProvider *self = CALLS_MM_PROVIDER (object);
self->watch_id =
......@@ -370,7 +369,7 @@ constructed (GObject *object)
g_debug ("Watching for ModemManager");
parent_class->constructed (object);
G_OBJECT_CLASS (calls_mm_provider_parent_class)->constructed (object);
}
......@@ -397,7 +396,6 @@ get_property (GObject *object,
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsMMProvider *self = CALLS_MM_PROVIDER (object);
if (self->watch_id)
......@@ -408,20 +406,19 @@ dispose (GObject *object)
clear_dbus (self);
parent_class->dispose (object);
G_OBJECT_CLASS (calls_mm_provider_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsMMProvider *self = CALLS_MM_PROVIDER (object);
g_hash_table_unref (self->origins);
g_free (self->status);
parent_class->finalize (object);
G_OBJECT_CLASS (calls_mm_provider_parent_class)->finalize (object);
}
......
......@@ -280,7 +280,6 @@ disconnect_reason_cb (CallsOfonoCall *self,
static void
constructed (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsOfonoCall *self = CALLS_OFONO_CALL (object);
g_return_if_fail (self->voice_call != NULL);
......@@ -290,33 +289,31 @@ constructed (GObject *object)
g_signal_connect_swapped (self->voice_call, "disconnect-reason",
G_CALLBACK (disconnect_reason_cb), self);
parent_class->constructed (object);
G_OBJECT_CLASS (calls_ofono_call_parent_class)->constructed (object);
}
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsOfonoCall *self = CALLS_OFONO_CALL (object);
g_clear_object (&self->voice_call);
parent_class->dispose (object);
G_OBJECT_CLASS (calls_ofono_call_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsOfonoCall *self = CALLS_OFONO_CALL (object);
g_free (self->disconnect_reason);
g_free (self->name);
g_free (self->number);
parent_class->finalize (object);
G_OBJECT_CLASS (calls_ofono_call_parent_class)->finalize (object);
}
......
......@@ -448,7 +448,6 @@ voice_new_cb (GDBusConnection *connection,
static void
constructed (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (object);
GDBusProxy *modem_proxy;
gchar *name;
......@@ -478,28 +477,26 @@ constructed (GObject *object)
g_clear_object (&self->modem);
parent_class->constructed (object);
G_OBJECT_CLASS (calls_ofono_origin_parent_class)->constructed (object);
}
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (object);
remove_calls (self, NULL);
g_clear_object (&self->modem);
g_clear_object (&self->connection);
parent_class->dispose (object);
G_OBJECT_CLASS (calls_ofono_origin_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (object);
if (self->tone_queue)
......@@ -508,7 +505,7 @@ finalize (GObject *object)
}
g_free (self->name);
parent_class->finalize (object);
G_OBJECT_CLASS (calls_ofono_origin_parent_class)->finalize (object);
}
......
......@@ -380,7 +380,6 @@ get_modems_cb (GDBOManager *manager,
static void
constructed (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsOfonoProvider *self = CALLS_OFONO_PROVIDER (object);
GError *error = NULL;
......@@ -415,33 +414,31 @@ constructed (GObject *object)
(GAsyncReadyCallback) get_modems_cb,
self);
parent_class->constructed (object);
G_OBJECT_CLASS (calls_ofono_provider_parent_class)->constructed (object);
}
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsOfonoProvider *self = CALLS_OFONO_PROVIDER (object);
g_clear_object (&self->manager);
g_clear_object (&self->connection);
parent_class->dispose (object);
G_OBJECT_CLASS (calls_ofono_provider_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsOfonoProvider *self = CALLS_OFONO_PROVIDER (object);
g_hash_table_unref (self->origins);
g_hash_table_unref (self->modems);
parent_class->finalize (object);
G_OBJECT_CLASS (calls_ofono_provider_parent_class)->finalize (object);
}
......
......@@ -423,7 +423,6 @@ app_open (GApplication *application,
static void
constructed (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (GTK_TYPE_APPLICATION);
CallsApplication *self = CALLS_APPLICATION (object);
GSimpleActionGroup *action_group;
......@@ -432,7 +431,7 @@ constructed (GObject *object)
actions, G_N_ELEMENTS (actions), self);
g_object_unref (action_group);
parent_class->constructed (object);
G_OBJECT_CLASS (calls_application_parent_class)->constructed (object);
}
......
......@@ -113,13 +113,12 @@ get_property (GObject *object,
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsCallData *self = CALLS_CALL_DATA (object);
g_clear_object (&self->call);
g_clear_object (&self->party);
parent_class->dispose (object);
G_OBJECT_CLASS (calls_call_data_parent_class)->dispose (object);
}
......
......@@ -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
......
......@@ -134,14 +134,13 @@ calls_call_holder_init (CallsCallHolder *self)
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsCallHolder *self = CALLS_CALL_HOLDER (object);
g_clear_object (&self->selector_item);
g_clear_object (&self->display);
g_clear_object (&self->data);
parent_class->dispose (object);
G_OBJECT_CLASS (calls_call_holder_parent_class)->dispose (object);
}
......
......@@ -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);
}
......
......@@ -146,7 +146,6 @@ set_property (GObject *object,
static void
finalize (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsCallRecord *self = CALLS_CALL_RECORD (object);
g_clear_pointer (&self->end, g_date_time_unref);
......@@ -154,7 +153,7 @@ finalize (GObject *object)
g_clear_pointer (&self->start, g_date_time_unref);
g_free (self->target);
parent_class->finalize (object);
G_OBJECT_CLASS (calls_call_record_parent_class)->finalize (object);
}
......
......@@ -152,12 +152,11 @@ calls_call_selector_item_init (CallsCallSelectorItem *self)
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (GTK_TYPE_EVENT_BOX);
CallsCallSelectorItem *self = CALLS_CALL_SELECTOR_ITEM (object);
g_clear_object (&self->display);
parent_class->dispose (object);
G_OBJECT_CLASS (calls_call_selector_item_parent_class)->dispose (object);
}
......
......@@ -639,7 +639,6 @@ notify (GObject *object,
static void
constructed (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (GTK_TYPE_APPLICATION_WINDOW);
CallsCallWindow *self = CALLS_CALL_WINDOW (object);
gtk_flow_box_bind_model (self->call_selector,
......@@ -649,7 +648,7 @@ constructed (GObject *object)
update_visibility (self);
parent_class->constructed (object);
G_OBJECT_CLASS (calls_call_window_parent_class)->constructed (object);
}
......@@ -665,7 +664,6 @@ calls_call_window_init (CallsCallWindow *self)
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (GTK_TYPE_APPLICATION_WINDOW);
CallsCallWindow *self = CALLS_CALL_WINDOW (object);
if (self->call_holders)
......@@ -676,7 +674,7 @@ dispose (GObject *object)
g_clear_object (&self->call_holders);
stop_info_timeout (self);
parent_class->dispose (object);
G_OBJECT_CLASS (calls_call_window_parent_class)->dispose (object);
}
......
......@@ -98,7 +98,6 @@ set_property (GObject *object,
static void
finalize (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsEnumerateParams *self = CALLS_ENUMERATE_PARAMS (object);
unsigned i;
......@@ -107,7 +106,7 @@ finalize (GObject *object)
g_hash_table_unref (self->callbacks[i]);
}
parent_class->finalize (object);
G_OBJECT_CLASS (calls_enumerate_params_parent_class)->finalize (object);
}
......
......@@ -151,7 +151,6 @@ set_property (GObject *object,
static void
constructed (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsHistoryBox *self = CALLS_HISTORY_BOX (object);
g_assert (self->model != NULL);
......@@ -174,21 +173,20 @@ constructed (GObject *object)
update (self);
parent_class->constructed (object);
G_OBJECT_CLASS (calls_history_box_parent_class)->constructed (object);
}
static void
dispose (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsHistoryBox *self = CALLS_HISTORY_BOX (object);
g_clear_object (&self->new_call);
g_clear_object (&self->contacts);
g_clear_object (&self->model);
parent_class->dispose (object);
G_OBJECT_CLASS (calls_history_box_parent_class)->dispose (object);
}
......
......@@ -254,7 +254,6 @@ set_up_provider (CallsMainWindow *self)
static void
constructed (GObject *object)
{
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
CallsMainWindow *self = CALLS_MAIN_WINDOW (object);
GSimpleActionGroup *simple_action_group;
GtkContainer *main_stack = GTK_CONTAINER (self->main_stack);
......@@ -309,7 +308,7 @@ constructed (GObject *object)
self->title_label,