Save read-only state in project file

When opening a database in read-only mode and creating a project file,
save the read-only flag in the project file.

When loading a project file with a read only flag set, open the database
in read-only mode.

See issue #1598.
This commit is contained in:
Martin Kleusberg
2018-11-08 16:36:09 +01:00
parent a81ea2b983
commit a8338406c9

View File

@@ -2615,6 +2615,10 @@ bool MainWindow::loadProject(QString filename, bool readOnly)
{
if(xml.name() == "db")
{
// Read only?
if(xml.attributes().hasAttribute("readonly"))
readOnly = xml.attributes().value("readonly").toInt();
// DB file
QString dbfilename = xml.attributes().value("path").toString();
if(!QFile::exists(dbfilename))
@@ -2887,6 +2891,7 @@ void MainWindow::saveProject()
// Database file name
xml.writeStartElement("db");
xml.writeAttribute("path", db.currentFile());
xml.writeAttribute("readonly", QString::number(db.readOnly()));
xml.writeAttribute("foreign_keys", db.getPragma("foreign_keys"));
xml.writeAttribute("case_sensitive_like", db.getPragma("case_sensitive_like"));
xml.writeAttribute("temp_store", db.getPragma("temp_store"));