From 363996497c9b439597d46f002e995055e368d7a8 Mon Sep 17 00:00:00 2001 From: "Nickolay V. Shmyrev" Date: Mon, 29 May 2006 15:35:29 +0000 Subject: [PATCH] Don't crash on reload. Fix for the bug #343167. * shell/ev-jobs.c: (ev_job_xfer_dispose), (ev_job_xfer_new): * shell/ev-jobs.h: * shell/ev-window.c: (ev_window_xfer_job_cb), (ev_window_open_uri), (ev_window_cmd_view_reload), (ev_window_init): Don't crash on reload. Fix for the bug #343167. --- ChangeLog | 9 +++++++++ shell/ev-jobs.c | 9 ++++++++- shell/ev-jobs.h | 3 ++- shell/ev-window.c | 26 +++++--------------------- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0ecadfc5..8b019ec0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-05-29 Nickolay V. Shmyrev <> + + * shell/ev-jobs.c: (ev_job_xfer_dispose), (ev_job_xfer_new): + * shell/ev-jobs.h: + * shell/ev-window.c: (ev_window_xfer_job_cb), (ev_window_open_uri), + (ev_window_cmd_view_reload), (ev_window_init): + + Don't crash on reload. Fix for the bug #343167. + 2006-05-28 Nickolay V. Shmyrev * shell/ev-jobs.c: (ev_job_render_run): diff --git a/shell/ev-jobs.c b/shell/ev-jobs.c index 8bd3d452..e9f29eb6 100644 --- a/shell/ev-jobs.c +++ b/shell/ev-jobs.c @@ -389,6 +389,11 @@ ev_job_xfer_dispose (GObject *object) job->error = NULL; } + if (job->dest) { + g_object_unref (job->dest); + job->dest = NULL; + } + (* G_OBJECT_CLASS (ev_job_xfer_parent_class)->dispose) (object); } @@ -404,13 +409,15 @@ ev_job_xfer_class_init (EvJobXferClass *class) EvJob * -ev_job_xfer_new (const gchar *uri) +ev_job_xfer_new (const gchar *uri, EvLinkDest *dest) { EvJobXfer *job; job = g_object_new (EV_TYPE_JOB_XFER, NULL); job->uri = g_strdup (uri); + if (dest) + job->dest = g_object_ref (dest); return EV_JOB (job); } diff --git a/shell/ev-jobs.h b/shell/ev-jobs.h index a7f6e825..bf9c86b6 100644 --- a/shell/ev-jobs.h +++ b/shell/ev-jobs.h @@ -162,6 +162,7 @@ struct _EvJobFontsClass struct _EvJobXfer { EvJob parent; + EvLinkDest *dest; GError *error; char *uri; char *local_uri; @@ -210,7 +211,7 @@ void ev_job_fonts_run (EvJobFonts *fonts); /* EvJobXfer */ GType ev_job_xfer_get_type (void); -EvJob *ev_job_xfer_new (const gchar *uri); +EvJob *ev_job_xfer_new (const gchar *uri, EvLinkDest *dest); void ev_job_xfer_run (EvJobXfer *xfer); G_END_DECLS diff --git a/shell/ev-window.c b/shell/ev-window.c index 8a6cf43e..e4b0ca0c 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -930,11 +930,11 @@ ev_window_xfer_job_cb (EvJobXfer *job, ev_window_setup_document (ev_window); ev_window_add_recent (ev_window, ev_window->priv->uri); - ev_window_clear_xfer_job (ev_window); - if (ev_window->priv->dest) - ev_window_goto_dest (ev_window, ev_window->priv->dest); - + if (job->dest) + ev_window_goto_dest (ev_window, job->dest); + + ev_window_clear_xfer_job (ev_window); return; } @@ -997,19 +997,12 @@ ev_window_close_dialogs (EvWindow *ev_window) void ev_window_open_uri (EvWindow *ev_window, const char *uri, EvLinkDest *dest) { - g_free (ev_window->priv->uri); - ev_window->priv->uri = NULL; - - if (ev_window->priv->dest) - g_object_unref (ev_window->priv->dest); - ev_window->priv->dest = dest ? g_object_ref (dest) : NULL; - ev_window_close_dialogs (ev_window); ev_window_clear_xfer_job (ev_window); ev_window_clear_local_uri (ev_window); ev_view_set_loading (EV_VIEW (ev_window->priv->view), TRUE); - ev_window->priv->xfer_job = ev_job_xfer_new (uri); + ev_window->priv->xfer_job = ev_job_xfer_new (uri, dest); g_signal_connect (ev_window->priv->xfer_job, "finished", G_CALLBACK (ev_window_xfer_job_cb), @@ -2072,20 +2065,13 @@ static void ev_window_cmd_view_reload (GtkAction *action, EvWindow *ev_window) { char *uri; - int page; g_return_if_fail (EV_IS_WINDOW (ev_window)); - page = ev_page_cache_get_current_page (ev_window->priv->page_cache); uri = g_strdup (ev_window->priv->uri); ev_window_open_uri (ev_window, uri, NULL); - /* In case the number of pages in the document has changed. */ - page = CLAMP (page, 0, ev_page_cache_get_n_pages (ev_window->priv->page_cache) - 1); - - ev_page_cache_set_current_page (ev_window->priv->page_cache, page); - g_free (uri); } @@ -3464,8 +3450,6 @@ ev_window_init (EvWindow *ev_window) ev_window->priv = EV_WINDOW_GET_PRIVATE (ev_window); - ev_window->priv->dest = NULL; - ev_window->priv->page_mode = PAGE_MODE_DOCUMENT; ev_window->priv->title = ev_window_title_new (ev_window); -- 2.43.5