summaryrefslogtreecommitdiff
path: root/src/application.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-10-13 00:58:30 +0200
committerAndrea Diamantini <adjam7@gmail.com>2011-10-13 00:58:30 +0200
commit8302ea16430afc414807c5251f04f129172e8995 (patch)
tree36068218068c283a747c62c441c5769e79d66d29 /src/application.cpp
parentCalm down kDebug messages (diff)
downloadrekonq-8302ea16430afc414807c5251f04f129172e8995.tar.xz
Fix crash on private mode store/restore
This commit, while does not perfectly fix the issue, "workaround" it a lot to fix crashes on private mode enter/exit - improve session store/restore - improve session manager code - calm down kDebug messages - applies code style CCBUG: 268328
Diffstat (limited to 'src/application.cpp')
-rw-r--r--src/application.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 39879e4c..6f9df43a 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -691,27 +691,38 @@ void Application::setPrivateBrowsingMode(bool b)
return;
}
+ sessionManager()->setSessionManagementEnabled(false);
settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
_privateBrowsingAction->setChecked(true);
+ loadUrl(KUrl("about:home"), Rekonq::NewWindow);
+
+ MainWindow *activeOne = m_mainWindows.at(0).data();
+
Q_FOREACH(const QWeakPointer<MainWindow> &w, m_mainWindows)
{
- w.data()->close();
+ if (w.data() != activeOne)
+ w.data()->close();
}
- loadUrl(KUrl("about:home"), Rekonq::NewWindow);
}
else
{
- Q_FOREACH(const QWeakPointer<MainWindow> &w, m_mainWindows)
- {
- w.data()->close();
- }
-
settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
_privateBrowsingAction->setChecked(false);
- if (!sessionManager()->restoreSessionFromScratch())
+ int newWindows = sessionManager()->restoreSavedSession();
+ if (newWindows == 0)
+ {
loadUrl(KUrl("about:home"), Rekonq::NewWindow);
+ newWindows++;
+ }
+
+ for (int i = newWindows; i < m_mainWindows.count(); ++i)
+ {
+ m_mainWindows.at(i).data()->close();
+ }
+
+ sessionManager()->setSessionManagementEnabled(true);
}
}