From 1ae1d06ca463e64fc49dae686ecdc4d8a0e5293a Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 24 Oct 2013 11:48:23 +0100 Subject: Reduce leaking of thumbnails to only for URLs that urldb rejects. Previously leaked thumbnails for all urls not previously visited. --- desktop/browser.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/browser.c b/desktop/browser.c index 55f576a85..d159a5599 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -1243,7 +1243,6 @@ static nserror browser_window_callback(hlcache_handle *c, if (bw->history_add && bw->history) { nsurl *url = hlcache_handle_get_url(c); - history_add(bw->history, c, bw->frag_id); if (urldb_add_url(url)) { urldb_set_url_title(url, content_get_title(c)); urldb_update_url_visit_data(url); @@ -1253,6 +1252,27 @@ static nserror browser_window_callback(hlcache_handle *c, /* This is safe as we've just added the URL */ global_history_add(urldb_get_url(url)); } + /* TODO: Urldb / Thumbnails / Local history brokenness + * + * We add to local history after calling urldb_add_url + * rather than in the block above. If urldb_add_url + * fails (as it will for urls like "about:about", + * "about:config" etc), there would be no local history + * node, and later calls to history_update will either + * explode or overwrite the node for the previous URL. + * + * We call it after, rather than before urldb_add_url + * because history_add calls thumbnail_create, which + * tries to register the thumbnail with urldb. That + * thumbnail registration fails if the url doesn't + * exist in urldb already, and only urldb-registered + * thumbnails get freed. So if we called history_add + * before urldb_add_url we would leak thumbnails for + * all newly visited URLs. With the history_add call + * after, we only leak the thumbnails when urldb does + * not add the URL. + */ + history_add(bw->history, c, bw->frag_id); } /* frames */ -- cgit v1.2.3