From 550e996a7a74974e16fe3301d0121ecf09acce37 Mon Sep 17 00:00:00 2001 From: Diego Escalante Urrelo Date: Fri, 22 Jan 2010 14:28:42 -0500 Subject: ephy-dialog: check if we get a valid EphyDialog This API is public but we are not really good checking we get valid EphyDialog objects when called, add some checks. Bug #607802 --- lib/ephy-dialog.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/ephy-dialog.c b/lib/ephy-dialog.c index 210283699..1cdbe295d 100644 --- a/lib/ephy-dialog.c +++ b/lib/ephy-dialog.c @@ -1144,6 +1144,8 @@ void ephy_dialog_set_modal (EphyDialog *dialog, gboolean is_modal) { + g_return_if_fail (EPHY_IS_DIALOG (dialog)); + dialog->priv->modal = is_modal != FALSE; gtk_window_set_modal (GTK_WINDOW(dialog->priv->dialog), is_modal); @@ -1170,6 +1172,8 @@ ephy_dialog_add_enum (EphyDialog *dialog, int i = 0; GList *l = NULL; + g_return_if_fail (EPHY_IS_DIALOG (dialog)); + info = lookup_info (dialog, property_id); g_return_if_fail (info != NULL); @@ -1197,6 +1201,8 @@ ephy_dialog_set_data_column (EphyDialog *dialog, { PropertyInfo *info; + g_return_if_fail (EPHY_IS_DIALOG (dialog)); + info = lookup_info (dialog, property_id); g_return_if_fail (info != NULL); @@ -1219,6 +1225,8 @@ ephy_dialog_set_pref (EphyDialog *dialog, { PropertyInfo *info; + g_return_if_fail (EPHY_IS_DIALOG (dialog)); + info = lookup_info (dialog, property_id); g_return_if_fail (info != NULL); @@ -1254,6 +1262,8 @@ ephy_dialog_set_size_group (EphyDialog *dialog, GtkSizeGroup *size_group; va_list vl; + g_return_if_fail (EPHY_IS_DIALOG (dialog)); + size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); va_start (vl, first_id); @@ -1309,7 +1319,11 @@ ephy_dialog_construct (EphyDialog *dialog, void ephy_dialog_show (EphyDialog *dialog) { - EphyDialogClass *klass = EPHY_DIALOG_GET_CLASS (dialog); + EphyDialogClass *klass; + + g_return_if_fail (EPHY_IS_DIALOG (dialog)); + + klass = EPHY_DIALOG_GET_CLASS (dialog); klass->show (dialog); } @@ -1334,11 +1348,13 @@ ephy_dialog_hide (EphyDialog *dialog) * * Runs gtk_dialog_run on @dialog and waits for a response. * - * Returns: the user response to gtk_dialog_run + * Returns: the user response to gtk_dialog_run or 0 if @dialog is not valid **/ int ephy_dialog_run (EphyDialog *dialog) { + g_return_val_if_fail (EPHY_IS_DIALOG (dialog), 0); + ephy_dialog_show (dialog); gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (dialog->priv->parent)), @@ -1354,6 +1370,7 @@ ephy_dialog_run (EphyDialog *dialog) * * Gets the internal widget corresponding to @property_id from @dialog. * Return value: (transfer none): the #GtkWidget corresponding to @property_id + * or %NULL **/ GtkWidget * ephy_dialog_get_control (EphyDialog *dialog, @@ -1361,6 +1378,8 @@ ephy_dialog_get_control (EphyDialog *dialog, { PropertyInfo *info; + g_return_val_if_fail (EPHY_IS_DIALOG (dialog), NULL); + info = lookup_info (dialog, property_id); g_return_val_if_fail (info != NULL, NULL); @@ -1421,6 +1440,8 @@ ephy_dialog_get_value (EphyDialog *dialog, { PropertyInfo *info; + g_return_val_if_fail (EPHY_IS_DIALOG (dialog), FALSE); + info = lookup_info (dialog, property_id); g_return_val_if_fail (info != NULL, FALSE); @@ -1442,6 +1463,8 @@ ephy_dialog_set_value (EphyDialog *dialog, { PropertyInfo *info; + g_return_if_fail (EPHY_IS_DIALOG (dialog)); + info = lookup_info (dialog, property_id); g_return_if_fail (info != NULL); @@ -1528,6 +1551,8 @@ void ephy_dialog_set_parent (EphyDialog *dialog, GtkWidget *parent) { + g_return_if_fail (EPHY_IS_DIALOG (dialog)); + dialog->priv->parent = parent; g_object_notify (G_OBJECT (dialog), "parent-window"); -- cgit