From 8cc34d5f6a359983ae6af24c42bfb0f27b32839f Mon Sep 17 00:00:00 2001 From: joshua Date: Mon, 30 Sep 2019 20:03:24 +0200 Subject: [PATCH] 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. --- sources/qetproject.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index 0e5995100..edd7ce22d 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -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); }