]> www.fi.muni.cz Git - evince.git/commitdiff
Use a const to return title so that we dont double free it. Small cleanup
authorMarco Pesenti Gritti <mpg@redhat.com>
Mon, 6 Jun 2005 09:53:45 +0000 (09:53 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Mon, 6 Jun 2005 09:53:45 +0000 (09:53 +0000)
2005-06-06  Marco Pesenti Gritti <mpg@redhat.com>

        * 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.

ChangeLog
backend/ev-page-cache.c
backend/ev-page-cache.h
shell/ev-window.c

index 16b6dc9705a4c80d6b514754b637836b8741b650..d7e1e2f7e8736b3dd71f9b01eb5ff9c977ab0e94 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-06-06  Marco Pesenti Gritti <mpg@redhat.com>
+
+       * 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 <mpg@redhat.com>
 
        * shell/ev-sidebar-links.c: (job_finished_callback),
index 17cd641437eaead3c315ab730b0e1c5470cffbc6..573e57e68b3e9a53a71961b7255cbfccbe7b9455 100644 (file)
@@ -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);
index 053fd366bdc2f3c6f93fe871183f9472b0981780..9de48b8f359bdb667034626a201a5544cf06771d 100644 (file)
@@ -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,
index 549539ed4547a1cfb686a5472210b2120dec7416..c7f0fadc46b7dcc1b586723aa071242456710fcc 100644 (file)
@@ -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;
                        }
                }