Skip to content

Commit 28a1c74

Browse files
committed
~ Changed default parameters profiles saving scheme and added version check.
1 parent dc3eb4a commit 28a1c74

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

DefaultParamsProfileManager.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <QtXml/QDomDocument>
44
#include "DefaultParamsProfileManager.h"
55
#include "DefaultParams.h"
6+
#include "version.h"
67

78
using namespace page_split;
89
using namespace output;
@@ -55,12 +56,22 @@ std::unique_ptr<DefaultParams> DefaultParamsProfileManager::readProfile(const QS
5556

5657
profileFile.close();
5758

58-
return std::make_unique<DefaultParams>(doc.documentElement());
59+
const QDomElement profileElement(doc.documentElement());
60+
const QString version = profileElement.attribute("version");
61+
if (version.isNull() || (version.toInt() != PROJECT_VERSION)) {
62+
return nullptr;
63+
}
64+
const QDomElement defaultParamsElement(profileElement.namedItem("default-params").toElement());
65+
66+
return std::make_unique<DefaultParams>(defaultParamsElement);
5967
}
6068

6169
bool DefaultParamsProfileManager::writeProfile(const DefaultParams& params, const QString& name) const {
6270
QDomDocument doc;
63-
doc.appendChild(params.toXml(doc, "profile"));
71+
QDomElement rootElement(doc.createElement("profile"));
72+
doc.appendChild(rootElement);
73+
rootElement.setAttribute("version", PROJECT_VERSION);
74+
rootElement.appendChild(params.toXml(doc, "default-params"));
6475

6576
QDir dir(path);
6677
if (!dir.exists()) {

0 commit comments

Comments
 (0)