[gnome-documents] pdf-loader: Terminate the unoconv process when loading is cancelled
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] pdf-loader: Terminate the unoconv process when loading is cancelled
- Date: Wed, 29 May 2013 15:46:07 +0000 (UTC)
commit 384a6629e58051632dcc5025660cf84bdd927efb
Author: Debarshi Ray <debarshir gnome org>
Date: Wed May 29 13:36:35 2013 +0200
pdf-loader: Terminate the unoconv process when loading is cancelled
https://bugzilla.gnome.org/show_bug.cgi?id=701139
src/lib/gd-pdf-loader.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/src/lib/gd-pdf-loader.c b/src/lib/gd-pdf-loader.c
index 61e4058..f98fed9 100644
--- a/src/lib/gd-pdf-loader.c
+++ b/src/lib/gd-pdf-loader.c
@@ -34,6 +34,7 @@
typedef struct {
GSimpleAsyncResult *result;
GCancellable *cancellable;
+ gulong cancelled_id;
EvDocument *document;
gchar *uri;
@@ -118,6 +119,11 @@ content_type_is_native (const gchar *content_type)
static void
pdf_load_job_free (PdfLoadJob *job)
{
+ if (job->cancellable != NULL) {
+ g_cancellable_disconnect (job->cancellable, job->cancelled_id);
+ job->cancelled_id = 0;
+ }
+
g_clear_object (&job->document);
g_clear_object (&job->result);
g_clear_object (&job->cancellable);
@@ -625,12 +631,28 @@ pdf_load_job_from_zpj_cache (PdfLoadJob *job)
}
static void
+unoconv_cancelled_cb (GCancellable *cancellable,
+ gpointer user_data)
+{
+ PdfLoadJob *job = user_data;
+
+ /* job->unoconv_pid will be reset by unoconv_child_watch_cb */
+ if (job->unoconv_pid != -1)
+ kill (job->unoconv_pid, SIGKILL);
+}
+
+static void
unoconv_child_watch_cb (GPid pid,
gint status,
gpointer user_data)
{
PdfLoadJob *job = user_data;
+ if (job->cancellable != NULL) {
+ g_cancellable_disconnect (job->cancellable, job->cancelled_id);
+ job->cancelled_id = 0;
+ }
+
g_spawn_close_pid (pid);
job->unoconv_pid = -1;
@@ -772,6 +794,9 @@ pdf_load_job_openoffice_refresh_cache (PdfLoadJob *job)
/* now watch when the unoconv child process dies */
g_child_watch_add (pid, unoconv_child_watch_cb, job);
job->unoconv_pid = pid;
+
+ if (job->cancellable != NULL)
+ job->cancelled_id = g_cancellable_connect (job->cancellable, G_CALLBACK (unoconv_cancelled_cb), job,
NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]