diff options
author | rbuj <[email protected]> | 2020-02-02 08:06:38 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-03-25 13:39:20 +0100 |
commit | e96ec69bd2fd1a2aa1032756a3d52d6d4d372d12 (patch) | |
tree | 9399f8248492fe378f12ffa7820fd317644dcf84 | |
parent | 7fdb280466fa41e94214c18db0a273e7a74ec3c7 (diff) | |
download | caja-extensions-e96ec69bd2fd1a2aa1032756a3d52d6d4d372d12.tar.bz2 caja-extensions-e96ec69bd2fd1a2aa1032756a3d52d6d4d372d12.tar.xz |
Fix memory leak allocated with 'gtk_builder_new ()'
-rw-r--r-- | image-converter/caja-image-resizer.c | 34 | ||||
-rw-r--r-- | image-converter/caja-image-rotator.c | 28 | ||||
-rw-r--r-- | sendto/caja-sendto-command.c | 34 |
3 files changed, 49 insertions, 47 deletions
diff --git a/image-converter/caja-image-resizer.c b/image-converter/caja-image-resizer.c index 63a0599..cf17cb2 100644 --- a/image-converter/caja-image-resizer.c +++ b/image-converter/caja-image-resizer.c @@ -336,35 +336,33 @@ caja_image_resizer_init(CajaImageResizer *resizer) { CajaImageResizerPrivate *priv = caja_image_resizer_get_instance_private (resizer); - GtkBuilder *ui; + GtkBuilder *builder; GError *err = NULL; - /* Let's create our gtkbuilder and load the xml file */ - ui = gtk_builder_new (); - gtk_builder_set_translation_domain (ui, GETTEXT_PACKAGE); - + builder = gtk_builder_new (); + gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE); /* If we're unable to load the xml file */ - if (gtk_builder_add_from_resource (ui, "/org/mate/caja/extensions/imageconverter/caja-image-resize.ui", &err) == 0) { + if (gtk_builder_add_from_resource (builder, "/org/mate/caja/extensions/imageconverter/caja-image-resize.ui", &err) == 0) { g_warning ("%s", err->message); g_error_free (err); return; } /* Grab some widgets */ - priv->resize_dialog = GTK_DIALOG (gtk_builder_get_object (ui, "resize_dialog")); + priv->resize_dialog = GTK_DIALOG (gtk_builder_get_object (builder, "resize_dialog")); priv->default_size_radiobutton = - GTK_RADIO_BUTTON (gtk_builder_get_object (ui, "default_size_radiobutton")); - priv->size_combobox = GTK_COMBO_BOX_TEXT (gtk_builder_get_object (ui, "comboboxtext_size")); + GTK_RADIO_BUTTON (gtk_builder_get_object (builder, "default_size_radiobutton")); + priv->size_combobox = GTK_COMBO_BOX_TEXT (gtk_builder_get_object (builder, "comboboxtext_size")); priv->custom_pct_radiobutton = - GTK_RADIO_BUTTON (gtk_builder_get_object (ui, "custom_pct_radiobutton")); - priv->pct_spinbutton = GTK_SPIN_BUTTON (gtk_builder_get_object (ui, "pct_spinbutton")); + GTK_RADIO_BUTTON (gtk_builder_get_object (builder, "custom_pct_radiobutton")); + priv->pct_spinbutton = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "pct_spinbutton")); priv->custom_size_radiobutton = - GTK_RADIO_BUTTON (gtk_builder_get_object (ui, "custom_size_radiobutton")); - priv->width_spinbutton = GTK_SPIN_BUTTON (gtk_builder_get_object (ui, "width_spinbutton")); - priv->height_spinbutton = GTK_SPIN_BUTTON (gtk_builder_get_object (ui, "height_spinbutton")); - priv->append_radiobutton = GTK_RADIO_BUTTON (gtk_builder_get_object (ui, "append_radiobutton")); - priv->name_entry = GTK_ENTRY (gtk_builder_get_object (ui, "name_entry")); - priv->inplace_radiobutton = GTK_RADIO_BUTTON (gtk_builder_get_object (ui, "inplace_radiobutton")); + GTK_RADIO_BUTTON (gtk_builder_get_object (builder, "custom_size_radiobutton")); + priv->width_spinbutton = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "width_spinbutton")); + priv->height_spinbutton = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "height_spinbutton")); + priv->append_radiobutton = GTK_RADIO_BUTTON (gtk_builder_get_object (builder, "append_radiobutton")); + priv->name_entry = GTK_ENTRY (gtk_builder_get_object (builder, "name_entry")); + priv->inplace_radiobutton = GTK_RADIO_BUTTON (gtk_builder_get_object (builder, "inplace_radiobutton")); /* Set default item in combo box */ /* gtk_combo_box_set_active (priv->size_combobox, 4); 1024x768 */ @@ -373,6 +371,8 @@ caja_image_resizer_init(CajaImageResizer *resizer) g_signal_connect (G_OBJECT (priv->resize_dialog), "response", (GCallback) caja_image_resizer_response_cb, resizer); + + g_object_unref (builder); } CajaImageResizer * diff --git a/image-converter/caja-image-rotator.c b/image-converter/caja-image-rotator.c index 733d971..fca0f8e 100644 --- a/image-converter/caja-image-rotator.c +++ b/image-converter/caja-image-rotator.c @@ -347,34 +347,32 @@ caja_image_rotator_init(CajaImageRotator *rotator) { CajaImageRotatorPrivate *priv = caja_image_rotator_get_instance_private (rotator); - GtkBuilder *ui; + GtkBuilder *builder; GError *err = NULL; - /* Let's create our gtkbuilder and load the xml file */ - ui = gtk_builder_new (); - gtk_builder_set_translation_domain (ui, GETTEXT_PACKAGE); - + builder = gtk_builder_new (); + gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE); /* If we're unable to load the xml file */ - if (gtk_builder_add_from_resource (ui, "/org/mate/caja/extensions/imageconverter/caja-image-rotate.ui", &err) == 0) { + if (gtk_builder_add_from_resource (builder, "/org/mate/caja/extensions/imageconverter/caja-image-rotate.ui", &err) == 0) { g_warning ("%s", err->message); g_error_free (err); return; } /* Grab some widgets */ - priv->rotate_dialog = GTK_DIALOG (gtk_builder_get_object (ui, "rotate_dialog")); + priv->rotate_dialog = GTK_DIALOG (gtk_builder_get_object (builder, "rotate_dialog")); priv->default_angle_radiobutton = - GTK_RADIO_BUTTON (gtk_builder_get_object (ui, "default_angle_radiobutton")); - priv->angle_combobox = GTK_COMBO_BOX (gtk_builder_get_object (ui, "angle_combobox")); + GTK_RADIO_BUTTON (gtk_builder_get_object (builder, "default_angle_radiobutton")); + priv->angle_combobox = GTK_COMBO_BOX (gtk_builder_get_object (builder, "angle_combobox")); priv->custom_angle_radiobutton = - GTK_RADIO_BUTTON (gtk_builder_get_object (ui, "custom_angle_radiobutton")); + GTK_RADIO_BUTTON (gtk_builder_get_object (builder, "custom_angle_radiobutton")); priv->angle_spinbutton = - GTK_SPIN_BUTTON (gtk_builder_get_object (ui, "angle_spinbutton")); + GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "angle_spinbutton")); priv->append_radiobutton = - GTK_RADIO_BUTTON (gtk_builder_get_object (ui, "append_radiobutton")); - priv->name_entry = GTK_ENTRY (gtk_builder_get_object (ui, "name_entry")); + GTK_RADIO_BUTTON (gtk_builder_get_object (builder, "append_radiobutton")); + priv->name_entry = GTK_ENTRY (gtk_builder_get_object (builder, "name_entry")); priv->inplace_radiobutton = - GTK_RADIO_BUTTON (gtk_builder_get_object (ui, "inplace_radiobutton")); + GTK_RADIO_BUTTON (gtk_builder_get_object (builder, "inplace_radiobutton")); /* Set default value for combobox */ gtk_combo_box_set_active (priv->angle_combobox, 0); /* 90° clockwise */ @@ -383,6 +381,8 @@ caja_image_rotator_init(CajaImageRotator *rotator) g_signal_connect (G_OBJECT (priv->rotate_dialog), "response", (GCallback) caja_image_rotator_response_cb, rotator); + + g_object_unref (builder); } CajaImageRotator * diff --git a/sendto/caja-sendto-command.c b/sendto/caja-sendto-command.c index 9b90041..f1f7397 100644 --- a/sendto/caja-sendto-command.c +++ b/sendto/caja-sendto-command.c @@ -522,7 +522,7 @@ update_button_image (GtkSettings *settings, static void caja_sendto_create_ui (void) { - GtkBuilder *app; + GtkBuilder *builder; GError* error = NULL; NS_ui *ui; gboolean one_file = FALSE; @@ -530,29 +530,29 @@ caja_sendto_create_ui (void) GtkSettings *gtk_settings; GtkWidget *button_image; - app = gtk_builder_new (); - if (gtk_builder_add_from_resource (app, "/org/mate/caja/extensions/sendto/caja-sendto.ui", &error) == 0) { + builder = gtk_builder_new (); + if (gtk_builder_add_from_resource (builder, "/org/mate/caja/extensions/sendto/caja-sendto.ui", &error) == 0) { g_warning ("Could not parse UI definition: %s", error->message); g_error_free (error); } ui = g_new0 (NS_ui, 1); - ui->hbox_contacts_ws = GTK_WIDGET (gtk_builder_get_object (app, "hbox_contacts_widgets")); - ui->send_to_label = GTK_WIDGET (gtk_builder_get_object (app, "send_to_label")); - ui->options_combobox = GTK_WIDGET (gtk_builder_get_object (app, "options_combobox")); - ui->dialog = GTK_WIDGET (gtk_builder_get_object (app, "caja_sendto_dialog")); - ui->cancel_button = GTK_WIDGET (gtk_builder_get_object (app, "cancel_button")); - ui->send_button = GTK_WIDGET (gtk_builder_get_object (app, "send_button")); - ui->pack_combobox = GTK_WIDGET (gtk_builder_get_object (app, "pack_combobox")); - ui->pack_entry = GTK_WIDGET (gtk_builder_get_object (app, "pack_entry")); - ui->pack_checkbutton = GTK_WIDGET (gtk_builder_get_object (app, "pack_checkbutton")); - ui->status_box = GTK_WIDGET (gtk_builder_get_object (app, "status_box")); - ui->status_label = GTK_WIDGET (gtk_builder_get_object (app, "status_label")); - ui->status_image = GTK_WIDGET (gtk_builder_get_object (app, "status_image")); + ui->hbox_contacts_ws = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_contacts_widgets")); + ui->send_to_label = GTK_WIDGET (gtk_builder_get_object (builder, "send_to_label")); + ui->options_combobox = GTK_WIDGET (gtk_builder_get_object (builder, "options_combobox")); + ui->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "caja_sendto_dialog")); + ui->cancel_button = GTK_WIDGET (gtk_builder_get_object (builder, "cancel_button")); + ui->send_button = GTK_WIDGET (gtk_builder_get_object (builder, "send_button")); + ui->pack_combobox = GTK_WIDGET (gtk_builder_get_object (builder, "pack_combobox")); + ui->pack_entry = GTK_WIDGET (gtk_builder_get_object (builder, "pack_entry")); + ui->pack_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "pack_checkbutton")); + ui->status_box = GTK_WIDGET (gtk_builder_get_object (builder, "status_box")); + ui->status_label = GTK_WIDGET (gtk_builder_get_object (builder, "status_label")); + ui->status_image = GTK_WIDGET (gtk_builder_get_object (builder, "status_image")); gtk_settings = gtk_settings_get_default (); - button_image = GTK_WIDGET (gtk_builder_get_object (app, "image1")); + button_image = GTK_WIDGET (gtk_builder_get_object (builder, "image1")); g_signal_connect (G_OBJECT (gtk_settings), "notify::gtk-button-images", G_CALLBACK (update_button_image), button_image); update_button_image (gtk_settings, NULL, button_image); @@ -605,6 +605,8 @@ caja_sendto_create_ui (void) g_signal_connect (G_OBJECT (ui->pack_checkbutton), "toggled", G_CALLBACK (toggle_pack_check), ui); + g_object_unref (builder); + if (has_dirs == FALSE || supports_dirs != FALSE) { gboolean toggle; |