mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Save previous crashed session that were not restored to session file
Closes #2331
This commit is contained in:
parent
d1becc23e9
commit
f2002892aa
@ -426,7 +426,7 @@ void MainApplication::openSession(BrowserWindow* window, RestoreData &restoreDat
|
||||
if (m_isRestoring)
|
||||
window->tabWidget()->closeRecoveryTab();
|
||||
|
||||
if (window->tabWidget()->normalTabsCount() > 1) {
|
||||
if (window->tabWidget()->count() != 0) {
|
||||
// This can only happen when recovering crashed session!
|
||||
// Don't restore tabs in current window as user already opened some new tabs.
|
||||
createWindow(Qz::BW_OtherRestoredWindow)->restoreWindow(restoreData.windows.takeAt(0));
|
||||
@ -452,6 +452,7 @@ bool MainApplication::restoreSession(BrowserWindow* window, RestoreData restoreD
|
||||
|
||||
openSession(window, restoreData);
|
||||
|
||||
m_restoreManager->clearRestoreData();
|
||||
destroyRestoreManager();
|
||||
m_isRestoring = false;
|
||||
|
||||
@ -460,6 +461,10 @@ bool MainApplication::restoreSession(BrowserWindow* window, RestoreData restoreD
|
||||
|
||||
void MainApplication::destroyRestoreManager()
|
||||
{
|
||||
if (m_restoreManager && m_restoreManager->isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Restore JavaScript settings
|
||||
const bool jsEnabled = Settings().value(QSL("Web-Browser-Settings/allowJavaScript"), true).toBool();
|
||||
m_webProfile->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, jsEnabled);
|
||||
@ -730,6 +735,11 @@ QByteArray MainApplication::saveState() const
|
||||
restoreData.windows.append(BrowserWindow::SavedWindow(window));
|
||||
}
|
||||
|
||||
if (m_restoreManager && m_restoreManager->isValid()) {
|
||||
QDataStream stream(&restoreData.crashedSession, QIODevice::WriteOnly);
|
||||
stream << m_restoreManager->restoreData();
|
||||
}
|
||||
|
||||
QByteArray data;
|
||||
QDataStream stream(&data, QIODevice::WriteOnly);
|
||||
|
||||
|
@ -78,6 +78,7 @@ void RecoveryJsObject::startNewSession()
|
||||
|
||||
m_page->load(window->homepageUrl());
|
||||
|
||||
mApp->restoreManager()->clearRestoreData();
|
||||
mApp->destroyRestoreManager();
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include <QFile>
|
||||
|
||||
static const int restoreDataVersion = 0;
|
||||
static const int restoreDataVersion = 1;
|
||||
|
||||
bool RestoreData::isValid() const
|
||||
{
|
||||
@ -42,6 +42,7 @@ QDataStream &operator<<(QDataStream &stream, const RestoreData &data)
|
||||
}
|
||||
|
||||
stream << restoreDataVersion;
|
||||
stream << data.crashedSession;
|
||||
|
||||
return stream;
|
||||
}
|
||||
@ -61,6 +62,10 @@ QDataStream &operator>>(QDataStream &stream, RestoreData &data)
|
||||
int version;
|
||||
stream >> version;
|
||||
|
||||
if (version >= 1) {
|
||||
stream >> data.crashedSession;
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
@ -80,6 +85,14 @@ RestoreData RestoreManager::restoreData() const
|
||||
return m_data;
|
||||
}
|
||||
|
||||
void RestoreManager::clearRestoreData()
|
||||
{
|
||||
m_data.clear();
|
||||
|
||||
QDataStream stream(&m_data.crashedSession, QIODevice::ReadOnly);
|
||||
stream >> m_data;
|
||||
}
|
||||
|
||||
bool RestoreManager::isValid() const
|
||||
{
|
||||
return m_data.isValid();
|
||||
|
@ -28,6 +28,7 @@ class RecoveryJsObject;
|
||||
struct QUPZILLA_EXPORT RestoreData
|
||||
{
|
||||
QVector<BrowserWindow::SavedWindow> windows;
|
||||
QByteArray crashedSession;
|
||||
|
||||
bool isValid() const;
|
||||
void clear();
|
||||
@ -44,6 +45,7 @@ public:
|
||||
|
||||
bool isValid() const;
|
||||
RestoreData restoreData() const;
|
||||
void clearRestoreData();
|
||||
|
||||
QObject *recoveryObject(WebPage *page);
|
||||
|
||||
|
@ -377,7 +377,7 @@ void SessionManager::openSessionManagerDialog()
|
||||
|
||||
void SessionManager::autoSaveLastSession()
|
||||
{
|
||||
if (mApp->isPrivate() || mApp->isRestoring() || mApp->windowCount() == 0 || mApp->restoreManager()) {
|
||||
if (mApp->isPrivate() || mApp->isRestoring() || mApp->windowCount() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -767,6 +767,10 @@ QList<WebTab*> TabWidget::allTabs(bool withPinned)
|
||||
|
||||
bool TabWidget::restoreState(const QVector<WebTab::SavedTab> &tabs, int currentTab)
|
||||
{
|
||||
if (tabs.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < tabs.size(); ++i) {
|
||||
WebTab::SavedTab tab = tabs.at(i);
|
||||
int index = addView(QUrl(), Qz::NT_CleanSelectedTab, false, tab.isPinned);
|
||||
|
@ -46,10 +46,6 @@ WebTab::SavedTab::SavedTab()
|
||||
|
||||
WebTab::SavedTab::SavedTab(WebTab* webTab)
|
||||
{
|
||||
if (webTab->url().toString() == QL1S("falkon:restore")) {
|
||||
return;
|
||||
}
|
||||
|
||||
title = webTab->title();
|
||||
url = webTab->url();
|
||||
icon = webTab->icon(true);
|
||||
|
Loading…
Reference in New Issue
Block a user