summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatgic78 <matgic78@gmail.com>2010-04-16 17:32:38 +0200
committermatgic78 <matgic78@gmail.com>2010-04-16 17:32:38 +0200
commitd8ea755c2b4ce9c22bf7543b3f345d90f434e8cf (patch)
treeb488d7663c74447bec64ad7cb179fc1d1e760451
parentFixing Lionel's merge request: (diff)
downloadrekonq-d8ea755c2b4ce9c22bf7543b3f345d90f434e8cf.tar.xz
Fix a bug in NewTabPage::snapFinished
When you started to load closedTabs and opened favorites, previews were replaced when background load of previews finished. Changes : - preview titles are saved only when urls match - previews are replaced only when urls match - added some checks to prevent NewTabPage to have strange behaviour in the future
-rw-r--r--src/newtabpage.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp
index 043648e7..d7671937 100644
--- a/src/newtabpage.cpp
+++ b/src/newtabpage.cpp
@@ -283,20 +283,9 @@ void NewTabPage::setupPreview(QWebElement e, int index)
void NewTabPage::snapFinished(int index, const KUrl &url, const QString &title)
{
- // do not try to modify the page if it isn't the newTabPage
- if(m_root.document().findAll("#rekonq-newtabpage").count() == 0)
- return;
-
- QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString());
- QWebElement newPrev = validPreview(index, url, title);
-
- if(m_root.findAll(".closedTabs").count() != 0)
- hideControls(newPrev);
-
- prev.replace(newPrev);
-
- // update title
- if(m_root.findAll(".favorites").count() != 0)
+ // Update title if necessary
+ QStringList urls = ReKonfig::previewUrls();
+ if(KUrl(urls.at(index)) == url)
{
QStringList names = ReKonfig::previewNames();
names.replace(index, title);
@@ -304,6 +293,23 @@ void NewTabPage::snapFinished(int index, const KUrl &url, const QString &title)
ReKonfig::self()->writeConfig();
}
+
+ // Update page, but only if open
+ if(m_root.document().findAll("#rekonq-newtabpage").count() == 0)
+ return;
+ if(m_root.findAll(".favorites").count() == 0 && m_root.findAll(".closedTabs").count() == 0)
+ return;
+
+ QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString());
+ if(KUrl(prev.findFirst("a").attribute("href")) == url)
+ {
+ QWebElement newPrev = validPreview(index, url, title);
+
+ if(m_root.findAll(".closedTabs").count() != 0)
+ hideControls(newPrev);
+
+ prev.replace(newPrev);
+ }
}