Skip to content

Commit

Permalink
Crash fix: Switch to top frame when parent frame is reloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
encounter committed Jan 28, 2015
1 parent a2912c2 commit 4c010f0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/webpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 4c010f0

Please sign in to comment.