summaryrefslogtreecommitdiff
path: root/src/history.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/history.c')
-rw-r--r--src/history.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/history.c b/src/history.c
index d1a731fb..50db33dd 100644
--- a/src/history.c
+++ b/src/history.c
@@ -254,18 +254,26 @@ const iString *url_History(const iHistory *d, size_t pos) {
254 return collectNew_String(); 254 return collectNew_String();
255} 255}
256 256
257iRecentUrl *findUrl_History(iHistory *d, const iString *url) { 257#if 0
258iRecentUrl *findUrl_History(iHistory *d, const iString *url, int timeDir) {
258 url = canonicalUrl_String(url); 259 url = canonicalUrl_String(url);
260// if (!timeDir) {
261// timeDir = -1;
262// }
259 lock_Mutex(d->mtx); 263 lock_Mutex(d->mtx);
260 iReverseForEach(Array, i, &d->recent) { 264 for (size_t i = size_Array(&d->recent) - 1 - d->recentPos; i < size_Array(&d->recent);
261 if (cmpStringCase_String(url, &((iRecentUrl *) i.value)->url) == 0) { 265 i += timeDir) {
266 iRecentUrl *item = at_Array(&d->recent, i);
267 if (cmpStringCase_String(url, &item->url) == 0) {
262 unlock_Mutex(d->mtx); 268 unlock_Mutex(d->mtx);
263 return i.value; 269 return item; /* FIXME: Returning an internal pointer; should remain locked. */
264 } 270 }
271 if (!timeDir) break;
265 } 272 }
266 unlock_Mutex(d->mtx); 273 unlock_Mutex(d->mtx);
267 return NULL; 274 return NULL;
268} 275}
276#endif
269 277
270void replace_History(iHistory *d, const iString *url) { 278void replace_History(iHistory *d, const iString *url) {
271 url = canonicalUrl_String(url); 279 url = canonicalUrl_String(url);
@@ -405,20 +413,18 @@ void setCachedDocument_History(iHistory *d, iGmDocument *doc, iBool openedFromSi
405 lock_Mutex(d->mtx); 413 lock_Mutex(d->mtx);
406 iRecentUrl *item = mostRecentUrl_History(d); 414 iRecentUrl *item = mostRecentUrl_History(d);
407 if (item) { 415 if (item) {
408 if (equal_String(url_GmDocument(doc), &item->url)) {
409 item->flags.openedFromSidebar = openedFromSidebar;
410 if (item->cachedDoc != doc) {
411 iRelease(item->cachedDoc);
412 item->cachedDoc = ref_Object(doc);
413 }
414 }
415#if !defined (NDEBUG) 416#if !defined (NDEBUG)
416 else { 417 if (!equal_String(url_GmDocument(doc), &item->url)) {
417 printf("[History] Not updating cached document; expecting {%s} but document URL is {%s}\n", 418 printf("[History] Cache mismatch! Expecting data for item {%s} but document URL is {%s}\n",
418 cstr_String(&item->url), 419 cstr_String(&item->url),
419 cstr_String(url_GmDocument(doc))); 420 cstr_String(url_GmDocument(doc)));
420 } 421 }
421#endif 422#endif
423 item->flags.openedFromSidebar = openedFromSidebar;
424 if (item->cachedDoc != doc) {
425 iRelease(item->cachedDoc);
426 item->cachedDoc = ref_Object(doc);
427 }
422 } 428 }
423 unlock_Mutex(d->mtx); 429 unlock_Mutex(d->mtx);
424} 430}