From 2473bc86466fd5642efb2c4f81714c04d2943b73 Mon Sep 17 00:00:00 2001 From: Jan Darmochwal Date: Thu, 4 Nov 2010 21:20:29 +0100 Subject: Fix for issue #781 This patch fixes issue #781 (http://lab.openslx.org/issues/781). Vmchooser wrote bad .xml files. --- src/vsession.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/vsession.cpp b/src/vsession.cpp index e2e359a..31602ed 100644 --- a/src/vsession.cpp +++ b/src/vsession.cpp @@ -47,7 +47,16 @@ QString VSession::icon() const { } QString VSession::toXml() const { - return this->doc_.toString(); + QDomDocument doc; + doc.appendChild(doc.createElement("settings")); + + doc.firstChild().appendChild(doc.importNode(doc_.documentElement(), true)); + + QDomNode xmlNode = doc.createProcessingInstruction( + "xml", "version=\"1.0\" encoding=\"UTF-8\""); + doc.insertBefore(xmlNode, doc.firstChild()); + + return doc.toString(); } QString VSession::getAttribute(const QString &nodeName, @@ -203,12 +212,9 @@ void VSession::mergePoolXml() { QFile file(poolXmlFile); if (!file.open(QIODevice::ReadOnly)) { - printf("mark a\n"); return; } if (!doc.setContent(&file)) { - printf("mark b\n"); - file.close(); return; } @@ -217,14 +223,11 @@ void VSession::mergePoolXml() { for (QDomElement envNode(doc.firstChildElement("environment")); !envNode.isNull(); envNode = envNode.nextSiblingElement()) { - printf("mark c\n"); - if (envNode.attribute("param") != pool) continue; for (QDomElement typeNode(envNode.firstChildElement()); !typeNode.isNull(); typeNode = typeNode.nextSiblingElement()) { - printf("mark d\n"); QString type = typeNode.nodeName(); if (type != "shared_folders" && type != "printers" && @@ -242,7 +245,6 @@ void VSession::mergePoolXml() { for (QDomElement el(typeNode.firstChildElement()); !el.isNull(); el = el.nextSiblingElement()) { - printf("mark e\n"); destinationNode.appendChild(this->doc_.importNode(el, true)); } } -- cgit v1.2.3-55-g7522