From: Marco Pesenti Gritti Date: Mon, 6 Jun 2005 09:53:45 +0000 (+0000) Subject: Use a const to return title so that we dont double free it. Small cleanup X-Git-Tag: EVINCE_0_3_3~275 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=2145e8deca567c91cf08132160f0ab3794fa382e;p=evince.git Use a const to return title so that we dont double free it. Small cleanup 2005-06-06 Marco Pesenti Gritti * backend/ev-page-cache.c: (_ev_page_cache_new): * backend/ev-page-cache.h: Use a const to return title so that we dont double free it. Small cleanup and fix a leak. * shell/ev-window.c: (update_window_title): strdup value from get_title. --- diff --git a/ChangeLog b/ChangeLog index 16b6dc97..d7e1e2f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-06-06 Marco Pesenti Gritti + + * backend/ev-page-cache.c: (_ev_page_cache_new): + * backend/ev-page-cache.h: + + Use a const to return title so that we dont double + free it. Small cleanup and fix a leak. + + * shell/ev-window.c: (update_window_title): + + strdup value from get_title. + 2005-06-06 Marco Pesenti Gritti * shell/ev-sidebar-links.c: (job_finished_callback), diff --git a/backend/ev-page-cache.c b/backend/ev-page-cache.c index 17cd6414..573e57e6 100644 --- a/backend/ev-page-cache.c +++ b/backend/ev-page-cache.c @@ -103,7 +103,6 @@ ev_page_cache_finalize (GObject *object) EvPageCache * _ev_page_cache_new (EvDocument *document) { - EvDocumentInfo *doc_info; EvPageCache *page_cache; EvPageCacheInfo *info; gint i; @@ -122,14 +121,13 @@ _ev_page_cache_new (EvDocument *document) page_cache->page_labels = g_new0 (char *, page_cache->n_pages); page_cache->max_width = 0; page_cache->max_height = 0; + page_cache->page_info = ev_document_get_info (document); - doc_info = ev_document_get_info (document); - if (doc_info->fields_mask & EV_DOCUMENT_INFO_TITLE) { - page_cache->title = g_strdup (doc_info->title); + if (page_cache->page_info->fields_mask & EV_DOCUMENT_INFO_TITLE) { + page_cache->title = g_strdup (page_cache->page_info->title); } else { page_cache->title = NULL; } - g_free (doc_info); for (i = 0; i < page_cache->n_pages; i++) { double page_width = 0; @@ -222,8 +220,6 @@ _ev_page_cache_new (EvDocument *document) } } - page_cache->page_info = ev_document_get_info (document); - /* make some sanity check assertions */ if (! page_cache->uniform) g_assert (page_cache->size_cache != NULL); @@ -317,7 +313,7 @@ ev_page_cache_set_link (EvPageCache *page_cache, ev_page_cache_set_current_page (page_cache, ev_link_get_page (link)); } -char * +const char * ev_page_cache_get_title (EvPageCache *page_cache) { g_return_val_if_fail (EV_IS_PAGE_CACHE (page_cache), NULL); diff --git a/backend/ev-page-cache.h b/backend/ev-page-cache.h index 053fd366..9de48b8f 100644 --- a/backend/ev-page-cache.h +++ b/backend/ev-page-cache.h @@ -33,7 +33,7 @@ GType ev_page_cache_get_type (void) G_GNUC_CONST; /* Used by ev-document.c only */ EvPageCache *_ev_page_cache_new (EvDocument *document); gint ev_page_cache_get_n_pages (EvPageCache *page_cache); -char *ev_page_cache_get_title (EvPageCache *page_cache); +const char *ev_page_cache_get_title (EvPageCache *page_cache); void ev_page_cache_get_size (EvPageCache *page_cache, gint page, gfloat scale, diff --git a/shell/ev-window.c b/shell/ev-window.c index 549539ed..c7f0fadc 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -520,13 +520,12 @@ update_window_title (EvDocument *document, GParamSpec *pspec, EvWindow *ev_windo password_needed = (ev_window->priv->password_document != NULL); if (document && ev_window->priv->page_cache) { - doc_title = ev_page_cache_get_title (ev_window->priv->page_cache); + doc_title = g_strdup (ev_page_cache_get_title (ev_window->priv->page_cache)); /* Make sure we get a valid title back */ if (doc_title) { if (doc_title[0] == '\000' || !g_utf8_validate (doc_title, -1, NULL)) { - g_free (doc_title); doc_title = NULL; } }