From 4c010f082b4988ede1553d65fb10320b0e344122 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 28 Jan 2015 15:58:25 -0500 Subject: [PATCH] Crash fix: Switch to top frame when parent frame is reloaded Fixes #10947 #11103 #11984 --- src/webpage.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/webpage.cpp b/src/webpage.cpp index ff1d43e95..a703a6bdc 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -357,7 +357,6 @@ 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_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::DirectConnection); connect(m_mainFrame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(setupFrame())); @@ -1522,8 +1521,15 @@ QStringList WebPage::childFramesName() const //< deprecated void WebPage::changeCurrentFrame(QWebFrame * const frame) { if (frame != m_currentFrame) { - qDebug() << "WebPage - changeCurrentFrame" << "from" << (m_currentFrame == NULL ? "Undefined" : m_currentFrame->frameName()) << "to" << frame->frameName(); - m_currentFrame = frame; + qDebug() << "WebPage - changeCurrentFrame" << "from" << m_currentFrame->frameName() << "to" << frame->frameName(); + QWebFrame * targetFrame = m_currentFrame; + while ((targetFrame = targetFrame->parentFrame()) != NULL) { + disconnect(targetFrame, SIGNAL(loadStarted()), this, SLOT(switchToMainFrame())); + } + m_currentFrame = targetFrame = frame; + while ((targetFrame = targetFrame->parentFrame()) != NULL) { + connect(targetFrame, SIGNAL(loadStarted()), this, SLOT(switchToMainFrame()), Qt::QueuedConnection); + } } }