Simplify how a project is save

Probably only on windows, sometime the .qet file is empty after saving.
With this commit we simplify the save function, by avoiding to import an
xml node from another one, so we minimize the risk of failure.
This commit is contained in:
joshua
2019-09-30 20:03:24 +02:00
parent eba9148924
commit 8cc34d5f6a

View File

@@ -889,12 +889,9 @@ QETResult QETProject::write()
if (isReadOnly() && !QFileInfo(m_file_path).isWritable())
return(QString("the file %1 was opened read-only and thus will not be written").arg(m_file_path));
//Get the project in xml
QDomDocument xml_project;
xml_project.appendChild(xml_project.importNode(toXml().documentElement(), true));
QDomDocument xml_project(toXml());
QString error_message;
if (!QET::writeXmlFile(xml_project, m_file_path, &error_message)) return(error_message);
if (!QET::writeXmlFile(xml_project, m_file_path, &error_message)) return(error_message);
//title block variables should be updated after file save dialog is confirmed, before file is saved.
m_project_properties.addValue("saveddate", QDate::currentDate().toString(Qt::SystemLocaleShortDate));
@@ -1679,8 +1676,7 @@ void QETProject::writeBackup()
return;
}
QDomDocument xml_project;
xml_project.appendChild(xml_project.importNode(toXml().documentElement(), true));
QDomDocument xml_project(toXml());
QET::writeToFile(xml_project, m_backup_file);
}