[tracker] tracker-extract: PDF: Don't let the PDF extractor work for more than 5s



commit d3493b9dc198cfc4fe30f9221cceb5518789a5d0
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed May 26 16:23:53 2010 +0200

    tracker-extract: PDF: Don't let the PDF extractor work for more than 5s

 src/tracker-extract/tracker-extract-pdf.cpp |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-pdf.cpp b/src/tracker-extract/tracker-extract-pdf.cpp
index 241b95b..347af86 100644
--- a/src/tracker-extract/tracker-extract-pdf.cpp
+++ b/src/tracker-extract/tracker-extract-pdf.cpp
@@ -285,6 +285,7 @@ extract_content (PDFDoc *document,
 	GString *string;
 	gint n_pages, i;
 	gsize n_bytes_remaining;
+	GTimer *timer;
 
 	n_pages = document->getNumPages();
 	string = g_string_new ("");
@@ -292,7 +293,10 @@ extract_content (PDFDoc *document,
 	n_bytes_remaining = n_bytes;
 	catalog = document->getCatalog();
 
-	while (i < n_pages && n_bytes_remaining > 0) {
+	timer = g_timer_new ();
+	g_timer_start (timer);
+
+	while (i < n_pages && n_bytes_remaining > 0 && g_timer_elapsed (timer, NULL) < 5) {
 		Gfx *gfx;
 		GooString *sel_text;
 		TextOutputDev *text_dev;
@@ -342,6 +346,8 @@ extract_content (PDFDoc *document,
 		delete text_dev;
 	}
 
+	g_timer_destroy (timer);
+
 	return g_string_free (string, FALSE);
 }
 



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