[epiphany/history-rewrite-second: 26/26] history-service: make sure we can update pages' titles and urls



commit d046baf13984378e08c5b6c6bc1a2fc7ce8ed2e5
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Mon Jan 23 23:19:09 2012 +0200

    history-service: make sure we can update pages' titles and urls
    
    When we retrieve a url from the backend from a user given
    EphyHistoryURL, it's possible for this to contain updated information
    for the page. In such case, don't overwrite this with the one stored
    in the backend.
    
    This makes possible to later update this information when saving a new
    visit.

 lib/history/ephy-history-service-urls-table.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/lib/history/ephy-history-service-urls-table.c b/lib/history/ephy-history-service-urls-table.c
index de0d516..0b72875 100644
--- a/lib/history/ephy-history-service-urls-table.c
+++ b/lib/history/ephy-history-service-urls-table.c
@@ -102,16 +102,17 @@ ephy_history_service_get_url_row (EphyHistoryService *self, const char *url_stri
 
   if (url == NULL) {
     url = ephy_history_url_new (NULL, NULL, 0, 0, 0, 1.0);
-  } else {
-    if (url->url)
-      g_free (url->url);
-    if (url->title)
-      g_free (url->title);
   }
 
   url->id = ephy_sqlite_statement_get_column_as_int (statement, 0);
-  url->url = g_strdup (ephy_sqlite_statement_get_column_as_string (statement, 1)),
-  url->title = g_strdup (ephy_sqlite_statement_get_column_as_string (statement, 2)),
+
+  /* Only get the URL and page title if we don't know it yet, as the version in the
+     history could be outdated. */
+  if (url->url == NULL)
+    url->url = g_strdup (ephy_sqlite_statement_get_column_as_string (statement, 1));
+  if (url->title == NULL)
+    url->title = g_strdup (ephy_sqlite_statement_get_column_as_string (statement, 2));
+
   url->visit_count = ephy_sqlite_statement_get_column_as_int (statement, 3),
   url->typed_count = ephy_sqlite_statement_get_column_as_int (statement, 4),
   url->last_visit_time = ephy_sqlite_statement_get_column_as_int (statement, 5);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]