SVN commit 951001 by dfaure: fix iterator mixup correctly M +2 -2 konqueror/src/konqhistorymanager.cpp M +12 -0 lib/konq/konq_historyentry.cpp M +6 -0 lib/konq/konq_historyentry.h M +8 -0 lib/konq/konq_historyprovider.cpp M +1 -0 lib/konq/konq_historyprovider.h --- trunk/KDE/kdebase/apps/konqueror/src/konqhistorymanager.cpp #951000:951001 @@ -139,8 +139,8 @@ // We add a copy of the current history entry of the url to the // pending list, so that we can restore it if the user canceled. // If there is no entry for the url yet, we just store the url. - KonqHistoryList::iterator oldEntry = findEntry( url ); - m_pending.insert( u, (oldEntry != entries().end()) ? + KonqHistoryList::const_iterator oldEntry = constFindEntry( url ); + m_pending.insert( u, (oldEntry != entries().constEnd()) ? new KonqHistoryEntry( *oldEntry ) : 0 ); } --- trunk/KDE/kdebase/apps/lib/konq/konq_historyentry.cpp #951000:951001 @@ -95,6 +95,18 @@ return end(); } +KonqHistoryList::const_iterator KonqHistoryList::constFindEntry( const KUrl& url ) const +{ + // we search backwards, probably faster to find an entry + KonqHistoryList::const_iterator it = constEnd(); + while ( it != constBegin() ) { + --it; + if ( (*it).url == url ) + return it; + } + return constEnd(); +} + void KonqHistoryList::removeEntry( const KUrl& url ) { iterator it = findEntry( url ); --- trunk/KDE/kdebase/apps/lib/konq/konq_historyentry.h #951000:951001 @@ -69,6 +69,12 @@ iterator findEntry( const KUrl& url ); /** + * Finds an entry by URL and return an iterator to it. + * If no matching entry is found, end() is returned. + */ + const_iterator constFindEntry( const KUrl& url ) const; + + /** * Finds an entry by URL and removes it */ void removeEntry( const KUrl& url ); --- trunk/KDE/kdebase/apps/lib/konq/konq_historyprovider.cpp #951000:951001 @@ -423,6 +423,14 @@ return d->m_history.findEntry(url); } +KonqHistoryList::const_iterator KonqHistoryProvider::constFindEntry(const KUrl& url) const +{ + // small optimization (dict lookup) for items _not_ in our history + if (!KParts::HistoryProvider::contains(url.url())) + return d->m_history.constEnd(); + return d->m_history.constFindEntry(url); +} + void KonqHistoryProvider::finishAddingEntry(const KonqHistoryEntry& entry, bool isSender) { Q_UNUSED(entry); // this arg is used by konq's reimplementation --- trunk/KDE/kdebase/apps/lib/konq/konq_historyprovider.h #951000:951001 @@ -144,6 +144,7 @@ * entries, as those are not added to the dict, currently. */ KonqHistoryList::iterator findEntry(const KUrl& url); + KonqHistoryList::const_iterator constFindEntry(const KUrl& url) const; /** * Notifies all running instances about a new HistoryEntry via D-Bus.