1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

[Session] Save session to QByteArray and then write it to file

Instead of appending data to file, write all session data at once.
This should help preventing corrupting session.dat file.

Closes #1247
This commit is contained in:
nowrep 2014-03-06 16:18:58 +01:00
parent f33552320f
commit d0d1fa1844

View File

@ -1188,9 +1188,8 @@ bool MainApplication::saveStateSlot()
return false;
}
QFile file(m_activeProfil + "session.dat");
file.open(QIODevice::WriteOnly);
QDataStream stream(&file);
QByteArray data;
QDataStream stream(&data, QIODevice::WriteOnly);
stream << Qz::sessionVersion;
stream << m_mainWindows.count();
@ -1208,13 +1207,17 @@ bool MainApplication::saveStateSlot()
stream << qz->saveState();
}
}
file.close();
BrowserWindow* qupzilla_ = getWindow();
if (qupzilla_ && m_mainWindows.count() == 1) {
qupzilla_->tabWidget()->savePinnedTabs();
}
QFile file(m_activeProfil + QLatin1String("session.dat"));
file.open(QIODevice::WriteOnly);
file.write(data);
file.close();
return true;
}