* 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. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@323 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
committed by
Alexandre Deckner
parent
e4b86f6ceb
commit
2e8e305ebc
@@ -154,7 +154,7 @@ BrowsingHistory::BrowsingHistory()
|
|||||||
|
|
||||||
BMessage historyItemArchive;
|
BMessage historyItemArchive;
|
||||||
for (int32 i = 0; settingsArchive.FindMessage("history item", i, &historyItemArchive) == B_OK; i++) {
|
for (int32 i = 0; settingsArchive.FindMessage("history item", i, &historyItemArchive) == B_OK; i++) {
|
||||||
addItem(BrowsingHistoryItem(&historyItemArchive));
|
privateAddItem(BrowsingHistoryItem(&historyItemArchive), false);
|
||||||
historyItemArchive.MakeEmpty();
|
historyItemArchive.MakeEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,28 +177,7 @@ bool BrowsingHistory::addItem(const BrowsingHistoryItem& item)
|
|||||||
{
|
{
|
||||||
BAutolock _(this);
|
BAutolock _(this);
|
||||||
|
|
||||||
int32 count = countItems();
|
return privateAddItem(item, false);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 BrowsingHistory::BrowsingHistory::countItems() const
|
int32 BrowsingHistory::BrowsingHistory::countItems() const
|
||||||
@@ -238,6 +217,37 @@ void BrowsingHistory::privateClear()
|
|||||||
m_historyItems.MakeEmpty();
|
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
|
// #pragma mark - private
|
||||||
|
|
||||||
void BrowsingHistory::saveSettings()
|
void BrowsingHistory::saveSettings()
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ private:
|
|||||||
BrowsingHistory();
|
BrowsingHistory();
|
||||||
virtual ~BrowsingHistory();
|
virtual ~BrowsingHistory();
|
||||||
void privateClear();
|
void privateClear();
|
||||||
|
bool privateAddItem(const BrowsingHistoryItem& item, bool invoke);
|
||||||
|
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
bool openSettingsFile(BFile& file, uint32 mode);
|
bool openSettingsFile(BFile& file, uint32 mode);
|
||||||
|
|||||||
Reference in New Issue
Block a user