diff options
-rw-r--r-- | roi.c | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -119,8 +119,7 @@ do_roi(struct roi *roi) calc_roi_interval(roi, match); g_object_unref(match); - if (roi->marked_image) - g_object_unref(roi->marked_image); + g_object_unref(roi->marked_image); roi->marked_image = gdk_pixbuf_copy(roi->image); mark_matching_pixels(roi, roi->marked_image); @@ -186,11 +185,9 @@ key_event(GtkWidget *widget, GdkEventKey *event, gpointer userdata) switch (event->keyval) { case GDK_KEY_d: case GDK_KEY_D: - if (roi->marked_image) { - g_object_unref(roi->marked_image); - roi->marked_image = NULL; - gtk_widget_queue_draw(roi->drawing_area); - } + g_object_unref(roi->marked_image); + roi->marked_image = g_object_ref(roi->image); + gtk_widget_queue_draw(roi->drawing_area); break; case GDK_KEY_q: case GDK_KEY_Q: @@ -225,8 +222,7 @@ draw_cb(GtkWidget *widget, cairo_t *cr, gpointer userdata) { struct roi *roi = userdata; - gdk_cairo_set_source_pixbuf(cr, roi->marked_image ? - roi->marked_image : roi->image, 0, 0); + gdk_cairo_set_source_pixbuf(cr, roi->marked_image, 0, 0); cairo_paint(cr); if (roi->doing_rubberband) @@ -249,6 +245,7 @@ main(int argc, char *argv[]) roi.image = gdk_pixbuf_new_from_file(argv[1], NULL); if (!roi.image) exit(EXIT_FAILURE); + roi.marked_image = g_object_ref(roi.image); roi.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); roi.drawing_area = gtk_drawing_area_new(); @@ -278,8 +275,7 @@ main(int argc, char *argv[]) gtk_main(); g_object_unref(roi.image); - if (roi.marked_image) - g_object_unref(roi.marked_image); + g_object_unref(roi.marked_image); return 0; } |