소스 검색

BUG: Fix unique key to allow multiple appsetting elements for QtTesting

Each custom app setting is record with the element "appsetting"
To allow mulitple custom setting we add to the key the command associated.
Benjamin Long 13 년 전
부모
커밋
16bc2f2bec
1개의 변경된 파일11개의 추가작업 그리고 4개의 파일을 삭제
  1. 11 4
      Libs/QtTesting/ctkXMLEventSource.cpp

+ 11 - 4
Libs/QtTesting/ctkXMLEventSource.cpp

@@ -72,7 +72,7 @@ void ctkXMLEventSource::setContent(const QString& xmlfilename)
   QFile xml(xmlfilename);
   if (!xml.open(QIODevice::ReadOnly))
     {
-    qDebug() << "Failed to load " << xmlfilename;
+    qCritical() << "Failed to load " << xmlfilename;
     return;
     }
 
@@ -81,7 +81,7 @@ void ctkXMLEventSource::setContent(const QString& xmlfilename)
   if (!xmlSchema.load(QUrl::fromLocalFile(":/XML/XMLDescription.xsd")) ||
       !xmlSchema.isValid())
     {
-    qDebug() << "Xml cannot be check.";
+    qCritical() << "Xml cannot be check.";
     return;
     }
 
@@ -200,7 +200,8 @@ bool ctkXMLEventSource::restoreApplicationSettings()
   for(iter = states.begin() ; iter!=states.end() ; ++iter)
     {
     iter.key()->setProperty(iter.value().toLatin1(),
-                            QVariant(this->OldSettings.value(iter.value())));
+                            QVariant(this->OldSettings.value(
+                              QString("appsetting_%1").arg(iter.value()))));
     }
 
 
@@ -219,7 +220,13 @@ QMap<QString, QString> ctkXMLEventSource::recoverSettingsFromXML()
     if (!this->XMLStream->name().isEmpty() &&
         this->XMLStream->tokenType() == QXmlStreamReader::StartElement)
       {
-      settings.insert(this->XMLStream->name().toString(),
+      QString key = this->XMLStream->name().toString();
+      // There might be multiple appsetting elements, ensure key is unique
+      if (this->XMLStream->name().toString() == "appsetting")
+        {
+        key += "_" + this->XMLStream->attributes().value("command").toString();
+        }
+      settings.insert(key,
                       this->XMLStream->attributes().value("arguments").toString());
       }
     }