From b1139933143d5134ffb943fee05ac8c90d4eb57a Mon Sep 17 00:00:00 2001 From: Ivan De Marino Date: Thu, 27 Sep 2012 01:42:11 +0100 Subject: [PATCH] MINOR: Avoid frame switching if already there. Useless to change frame if it's already the right one. Makes it clearer what is going on when debugging. --- src/webpage.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/webpage.cpp b/src/webpage.cpp index 29d13c8c..11c58b9b 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -297,8 +297,8 @@ WebPage::WebPage(QObject *parent, const QUrl &baseUrl) // (no parameter == main frame) but we make sure to do the setup only once. // // @see WebPage::setupFrame(QWebFrame *) for details. - connect(m_customWebPage, SIGNAL(loadStarted()), this, SLOT(switchToMainFrame()), Qt::QueuedConnection); - connect(m_customWebPage, SIGNAL(loadFinished(bool)), this, SLOT(setupFrame()), Qt::QueuedConnection); + connect(m_mainFrame, SIGNAL(loadStarted()), this, SLOT(switchToMainFrame()), Qt::QueuedConnection); + connect(m_mainFrame, SIGNAL(loadFinished(bool)), this, SLOT(setupFrame()), Qt::QueuedConnection); connect(m_customWebPage, SIGNAL(frameCreated(QWebFrame*)), this, SLOT(setupFrame(QWebFrame*)), Qt::QueuedConnection); connect(m_mainFrame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(setupFrame())); connect(m_mainFrame, SIGNAL(javaScriptWindowObjectCleared()), SIGNAL(initialized())); @@ -1277,8 +1277,10 @@ QStringList WebPage::childFramesName() const //< deprecated void WebPage::changeCurrentFrame(QWebFrame * const frame) { - qDebug() << "WebPage - changeCurrentFrame" << "from" << m_currentFrame->frameName() << "to" << frame->frameName(); - m_currentFrame = frame; + if (frame != m_currentFrame) { + qDebug() << "WebPage - changeCurrentFrame" << "from" << m_currentFrame->frameName() << "to" << frame->frameName(); + m_currentFrame = frame; + } } bool WebPage::switchToFrame(const QString &frameName) @@ -1315,7 +1317,9 @@ bool WebPage::switchToChildFrame(const int framePosition) //< deprecated void WebPage::switchToMainFrame() { - this->changeCurrentFrame(m_mainFrame); + if (m_currentFrame != m_mainFrame) { + this->changeCurrentFrame(m_mainFrame); + } } bool WebPage::switchToParentFrame()