[recipes] Fix up image array handling
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Fix up image array handling
- Date: Mon, 15 May 2017 22:40:57 +0000 (UTC)
commit 67ee79f43d62d0956f358e154d14e5fb12c0d89a
Author: Matthias Clasen <mclasen redhat com>
Date: Mon May 15 18:38:44 2017 -0400
Fix up image array handling
We were using generic GObject api in several places, and got
the refcounting wrong in some of them, leading to crashes.
Instead, use the getters we have.
http://bugzilla.gnome.org/show_bug.cgi?id=7825644
src/gr-cooking-page.c | 4 ++--
src/gr-details-page.c | 5 +++--
src/gr-image-page.c | 3 ++-
src/gr-recipe-store.c | 5 ++---
4 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/src/gr-cooking-page.c b/src/gr-cooking-page.c
index 5d934fc..1bbbbc5 100644
--- a/src/gr-cooking-page.c
+++ b/src/gr-cooking-page.c
@@ -530,13 +530,13 @@ void
gr_cooking_page_set_recipe (GrCookingPage *page,
GrRecipe *recipe)
{
- g_autoptr(GPtrArray) images = NULL;
+ GPtrArray *images;
const char *id;
const char *instructions;
g_set_object (&page->recipe, recipe);
- g_object_get (recipe, "images", &images, NULL);
+ images = gr_recipe_get_images (recipe);
id = gr_recipe_get_id (recipe);
instructions = gr_recipe_get_translated_instructions (recipe);
diff --git a/src/gr-details-page.c b/src/gr-details-page.c
index edb7f87..b96467f 100644
--- a/src/gr-details-page.c
+++ b/src/gr-details-page.c
@@ -349,10 +349,11 @@ static void
activate_image (GrDetailsPage *page)
{
GtkWidget *window;
- g_autoptr(GPtrArray) images = NULL;
+ GPtrArray *images = NULL;
int idx;
- g_object_get (page->recipe_image, "images", &images, "index", &idx, NULL);
+ images = gr_image_viewer_get_images (GR_IMAGE_VIEWER (page->recipe_image));
+ idx = gr_image_viewer_get_index (GR_IMAGE_VIEWER (page->recipe_image));
window = gtk_widget_get_ancestor (GTK_WIDGET (page->recipe_image), GTK_TYPE_APPLICATION_WINDOW);
gr_window_show_image (GR_WINDOW (window), images, idx);
diff --git a/src/gr-image-page.c b/src/gr-image-page.c
index 84c285e..985556c 100644
--- a/src/gr-image-page.c
+++ b/src/gr-image-page.c
@@ -313,9 +313,10 @@ gr_image_page_set_images (GrImagePage *page,
{
g_object_freeze_notify (G_OBJECT (page));
+ g_ptr_array_ref (images);
g_ptr_array_unref (page->images);
- page->images = g_ptr_array_ref (images);
+ page->images = images;
page->index = 0;
set_current_image (page);
diff --git a/src/gr-recipe-store.c b/src/gr-recipe-store.c
index c9bce32..633e997 100644
--- a/src/gr-recipe-store.c
+++ b/src/gr-recipe-store.c
@@ -530,7 +530,7 @@ save_recipes (GrRecipeStore *self)
const char *ingredients;
const char *instructions;
const char *notes;
- g_autoptr(GPtrArray) images = NULL;
+ GPtrArray *images;
int serves;
int spiciness;
GrDiets diets;
@@ -562,8 +562,7 @@ save_recipes (GrRecipeStore *self)
mtime = gr_recipe_get_mtime (recipe);
default_image = gr_recipe_get_default_image (recipe);
readonly = gr_recipe_is_readonly (recipe);
-
- g_object_get (recipe, "images", &images, NULL);
+ images = gr_recipe_get_images (recipe);
paths = g_new0 (char *, images->len + 1);
for (i = 0; i < images->len; i++) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]