Commit 695c6b3b authored by Vivek Yadav's avatar Vivek Yadav Committed by Jean-Baptiste Mardelle
Browse files

Update effecttreemodel.cpp

parent ec97c564
...@@ -214,16 +214,16 @@ void EffectTreeModel::editCustomAsset(const QString newName,const QString newDes ...@@ -214,16 +214,16 @@ void EffectTreeModel::editCustomAsset(const QString newName,const QString newDes
if(!newDescription.trimmed().isEmpty()){ if(!newDescription.trimmed().isEmpty()){
QDomElement root = doc.documentElement(); QDomElement root = doc.documentElement();
QDomElement nodelist = root.firstChildElement("description"); QDomElement nodelist = root.firstChildElement("description");
QDomElement newNodeTag = doc.createElement(QString("description")); QDomElement newNodeTag = doc.createElement(QString("description"));
QDomText text = doc.createTextNode(newDescription); QDomText text = doc.createTextNode(newDescription);
newNodeTag.appendChild(text); newNodeTag.appendChild(text);
root.replaceChild(newNodeTag, nodelist); root.replaceChild(newNodeTag, nodelist);
} }
if(!newName.trimmed().isEmpty()) if(!newName.trimmed().isEmpty() && newName != currentName)
{ {
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/effects/")); QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/effects/"));
if (!dir.exists()) { if (!dir.exists()) {
...@@ -249,24 +249,24 @@ void EffectTreeModel::editCustomAsset(const QString newName,const QString newDes ...@@ -249,24 +249,24 @@ void EffectTreeModel::editCustomAsset(const QString newName,const QString newDes
e.setAttribute("id", newName); e.setAttribute("id", newName);
if (file.open(QFile::WriteOnly | QFile::Truncate)) { if (file.open(QFile::WriteOnly | QFile::Truncate)) {
QTextStream out(&file); QTextStream out(&file);
out << doc.toString(); out << doc.toString();
} }
file.close(); file.close();
deleteEffect(index); deleteEffect(index);
reloadEffect(dir.absoluteFilePath(newName + QStringLiteral(".xml"))); reloadEffect(dir.absoluteFilePath(newName + QStringLiteral(".xml")));
} }
else else
{ {
QFile file(dir.absoluteFilePath(currentName + QStringLiteral(".xml"))); QFile file(dir.absoluteFilePath(currentName + QStringLiteral(".xml")));
if (file.open(QFile::WriteOnly | QFile::Truncate)) { if (file.open(QFile::WriteOnly | QFile::Truncate)) {
QTextStream out(&file); QTextStream out(&file);
out << doc.toString(); out << doc.toString();
} }
file.close(); file.close();
reloadEffect(oldpath); reloadEffect(oldpath);
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment