[evince] Don't mix PopplerRectangle and EvRectangle



commit 8d62af1f60cf9775352342867736df3e7f488b43
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Mon Jun 14 19:27:08 2010 +0200

    Don't mix PopplerRectangle and EvRectangle
    
    We shouldn't assume a PopplerRectangle was created with g_new(), so
    better use poppler_rectangle_free().

 backend/djvu/djvu-text-page.c |    2 +-
 backend/pdf/ev-poppler.cc     |   23 ++++++++++++++++-------
 libview/ev-jobs.c             |    2 +-
 3 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/backend/djvu/djvu-text-page.c b/backend/djvu/djvu-text-page.c
index 10fe1a4..3f171d1 100644
--- a/backend/djvu/djvu-text-page.c
+++ b/backend/djvu/djvu-text-page.c
@@ -233,7 +233,7 @@ djvu_text_page_sexpr_process (DjvuTextPage *page,
                               miniexp_t     end)
 {
 	if (page->bounding_box || p == start) {
-		EvRectangle *new_rectangle = g_new (EvRectangle, 1);
+		EvRectangle *new_rectangle = ev_rectangle_new ();
 		new_rectangle->x1 = miniexp_to_int (miniexp_nth (1, p));
 		new_rectangle->y1 = miniexp_to_int (miniexp_nth (2, p));
 		new_rectangle->x2 = miniexp_to_int (miniexp_nth (3, p));
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index 6d660b6..e9657d9 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -1555,7 +1555,8 @@ pdf_document_find_find_text (EvDocumentFind *document_find,
 	GList *matches, *l;
 	PopplerPage *poppler_page;
 	gdouble height;
-	
+	GList *retval = NULL;
+
 	g_return_val_if_fail (POPPLER_IS_PAGE (page->backend_page), NULL);
 	g_return_val_if_fail (text != NULL, NULL);
 
@@ -1568,14 +1569,22 @@ pdf_document_find_find_text (EvDocumentFind *document_find,
 	poppler_page_get_size (poppler_page, NULL, &height);
 	for (l = matches; l && l->data; l = g_list_next (l)) {
 		PopplerRectangle *rect = (PopplerRectangle *)l->data;
-		gdouble           tmp;
+		EvRectangle      *ev_rect;
+
+		ev_rect = ev_rectangle_new ();
+		ev_rect->x1 = rect->x1;
+		ev_rect->x2 = rect->x2;
+		/* Invert this for X-style coordinates */
+		ev_rect->y1 = height - rect->y2;
+		ev_rect->y2 = height - rect->y1;
 
-		tmp = rect->y1;
-		rect->y1 = height - rect->y2;
-		rect->y2 = height - tmp;
+		retval = g_list_prepend (retval, ev_rect);
 	}
-	
-	return matches;
+
+	g_list_foreach (matches, (GFunc)poppler_rectangle_free, NULL);
+	g_list_free (matches);
+
+	return g_list_reverse (retval);
 }
 
 static void
diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c
index 5cbb6d5..140c51a 100644
--- a/libview/ev-jobs.c
+++ b/libview/ev-jobs.c
@@ -1087,7 +1087,7 @@ ev_job_find_dispose (GObject *object)
 		gint i;
 
 		for (i = 0; i < job->n_pages; i++) {
-			g_list_foreach (job->pages[i], (GFunc)g_free, NULL);
+			g_list_foreach (job->pages[i], (GFunc)ev_rectangle_free, NULL);
 			g_list_free (job->pages[i]);
 		}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]