From eaa64d066e4b4e7e85d5045e5cb16ab2c19716f9 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 7 Feb 2005 21:51:28 +0000 Subject: [PATCH] Some cleanups, stop the interpreter on finalize 2005-02-07 Marco Pesenti Gritti * ps/ps-document.c: (ps_document_finalize), (ps_document_get_n_pages), (ps_document_get_page): Some cleanups, stop the interpreter on finalize * shell/ev-page-view.c: (ev_page_view_dispose), (ev_page_view_class_init): Release our reference on the document --- ChangeLog | 12 ++++++++ ps/ps-document.c | 66 +++++++++++++++++++------------------------- shell/ev-page-view.c | 15 ++++++++++ 3 files changed, 55 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index f789a601..ab798108 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-02-07 Marco Pesenti Gritti + + * ps/ps-document.c: (ps_document_finalize), + (ps_document_get_n_pages), (ps_document_get_page): + + Some cleanups, stop the interpreter on finalize + + * shell/ev-page-view.c: (ev_page_view_dispose), + (ev_page_view_class_init): + + Release our reference on the document + 2005-02-07 Marco Pesenti Gritti * Makefile.am: diff --git a/ps/ps-document.c b/ps/ps-document.c index 0e4f3693..c7263bc1 100644 --- a/ps/ps-document.c +++ b/ps/ps-document.c @@ -389,23 +389,26 @@ ps_document_cleanup(PSDocument * gs) } static void -ps_document_finalize(GObject * object) +ps_document_finalize (GObject * object) { - PSDocument *gs; + PSDocument *gs; - g_return_if_fail(object != NULL); - g_return_if_fail(GTK_IS_GS(object)); + g_return_if_fail (object != NULL); + g_return_if_fail (GTK_IS_GS (object)); - gs = PS_DOCUMENT(object); + LOG ("Finalize") - ps_document_cleanup(gs); + gs = PS_DOCUMENT (object); - if(gs->input_buffer) { - g_free(gs->input_buffer); - gs->input_buffer = NULL; - } + ps_document_cleanup (gs); + stop_interpreter (gs); + + if(gs->input_buffer) { + g_free(gs->input_buffer); + gs->input_buffer = NULL; + } - (*G_OBJECT_CLASS(parent_class)->finalize) (object); + (*G_OBJECT_CLASS(parent_class)->finalize) (object); } static void @@ -1431,31 +1434,6 @@ ps_document_next_page(PSDocument * gs) return TRUE; } -static gint -ps_document_get_current_page(PSDocument * gs) -{ - g_return_val_if_fail(gs != NULL, -1); - g_return_val_if_fail(GTK_IS_GS(gs), -1); - - return gs->current_page; -} - -static gint -ps_document_get_page_count(PSDocument * gs) -{ - if(!gs->gs_filename) - return 0; - - if(gs->doc) { - if(gs->structured_doc) - return gs->doc->numpages; - else - return G_MAXINT; - } - else - return 0; -} - static gboolean ps_document_goto_page(PSDocument * gs, gint page) { @@ -1732,7 +1710,15 @@ ps_document_save (EvDocument *document, static int ps_document_get_n_pages (EvDocument *document) { - return ps_document_get_page_count (PS_DOCUMENT (document)); + PSDocument *ps = PS_DOCUMENT (document); + + g_return_val_if_fail (ps != NULL, -1); + + if (!ps->gs_filename || !ps->doc) { + return -1; + } + + return ps->structured_doc ? ps->doc->numpages : 1; } static void @@ -1745,7 +1731,11 @@ ps_document_set_page (EvDocument *document, static int ps_document_get_page (EvDocument *document) { - return ps_document_get_current_page (PS_DOCUMENT (document)); + PSDocument *ps = PS_DOCUMENT (document); + + g_return_val_if_fail (ps != NULL, -1); + + return ps->current_page; } static gboolean diff --git a/shell/ev-page-view.c b/shell/ev-page-view.c index 050e3cc8..4b019c4b 100644 --- a/shell/ev-page-view.c +++ b/shell/ev-page-view.c @@ -97,6 +97,19 @@ ev_page_view_init (EvPageView *page_view) page_view->priv->uniform_page_size = FALSE; } +static void +ev_page_view_dispose (GObject *object) +{ + EvPageView *view = EV_PAGE_VIEW (object); + + if (view->priv->document) { + g_object_unref (view->priv->document); + view->priv->document = NULL; + } + + G_OBJECT_CLASS (ev_page_view_parent_class)->dispose (object); +} + static void ev_page_view_class_init (EvPageViewClass *klass) { @@ -115,6 +128,8 @@ ev_page_view_class_init (EvPageViewClass *klass) widget_class->unrealize = ev_page_view_unrealize; widget_class->map = ev_page_view_map; + o_class->dispose = ev_page_view_dispose; + widget_class->set_scroll_adjustments_signal = g_signal_new ("set_scroll_adjustments", G_TYPE_FROM_CLASS (o_class), -- 2.43.5