Author: stippi Date: Wed Mar 17 19:39:46 2010 New Revision: 323 URL: http://mmlr.dyndns.org/changeset/323 Log: * Fixed bug that would save the history for each item in the history when loading the history from disk... * Don't touch items when loading them from disk, messing up their visited time. Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowsingHistory.cpp webkit/trunk/WebKit/haiku/WebPositive/BrowsingHistory.h Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowsingHistory.cpp ============================================================================== --- webkit/trunk/WebKit/haiku/WebPositive/BrowsingHistory.cpp Wed Mar 17 19:38:23 2010 (r322) +++ webkit/trunk/WebKit/haiku/WebPositive/BrowsingHistory.cpp Wed Mar 17 19:39:46 2010 (r323) @@ -154,7 +154,7 @@ BMessage historyItemArchive; for (int32 i = 0; settingsArchive.FindMessage("history item", i, &historyItemArchive) == B_OK; i++) { - addItem(BrowsingHistoryItem(&historyItemArchive)); + privateAddItem(BrowsingHistoryItem(&historyItemArchive), false); historyItemArchive.MakeEmpty(); } } @@ -177,28 +177,7 @@ { BAutolock _(this); - int32 count = countItems(); - int32 insertionIndex = count; - for (int32 i = 0; i < count; i++) { - BrowsingHistoryItem* existingItem = reinterpret_cast<BrowsingHistoryItem*>( - m_historyItems.ItemAtFast(i)); - if (item.url() == existingItem->url()) { - existingItem->invoked(); - return true; - } - if (item < *existingItem) - insertionIndex = i; - } - BrowsingHistoryItem* newItem = new(std::nothrow) BrowsingHistoryItem(item); - if (!newItem || !m_historyItems.AddItem(newItem, insertionIndex)) { - delete newItem; - return false; - } - - newItem->invoked(); - saveSettings(); - - return true; + return privateAddItem(item, false); } int32 BrowsingHistory::BrowsingHistory::countItems() const @@ -238,6 +217,37 @@ m_historyItems.MakeEmpty(); } +bool BrowsingHistory::privateAddItem(const BrowsingHistoryItem& item, bool internal) +{ + int32 count = countItems(); + int32 insertionIndex = count; + for (int32 i = 0; i < count; i++) { + BrowsingHistoryItem* existingItem = reinterpret_cast<BrowsingHistoryItem*>( + m_historyItems.ItemAtFast(i)); + if (item.url() == existingItem->url()) { + if (!internal) { + existingItem->invoked(); + saveSettings(); + } + return true; + } + if (item < *existingItem) + insertionIndex = i; + } + BrowsingHistoryItem* newItem = new(std::nothrow) BrowsingHistoryItem(item); + if (!newItem || !m_historyItems.AddItem(newItem, insertionIndex)) { + delete newItem; + return false; + } + + if (!internal) { + newItem->invoked(); + saveSettings(); + } + + return true; +} + // #pragma mark - private void BrowsingHistory::saveSettings() Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowsingHistory.h ============================================================================== --- webkit/trunk/WebKit/haiku/WebPositive/BrowsingHistory.h Wed Mar 17 19:38:23 2010 (r322) +++ webkit/trunk/WebKit/haiku/WebPositive/BrowsingHistory.h Wed Mar 17 19:39:46 2010 (r323) @@ -79,6 +79,7 @@ BrowsingHistory(); virtual ~BrowsingHistory(); void privateClear(); + bool privateAddItem(const BrowsingHistoryItem& item, bool invoke); void saveSettings(); bool openSettingsFile(BFile& file, uint32 mode);