Problem with ApplicationProperties serialization


#1

I must have missed something but when I serialize my app properties, the XML is escaped and written as an attribute instead of being written as a tree. This behaviour happens only under windows, Mac version works fine . 

The code : 


  ScopedPointer<XmlElement> xml( mData.createXml() );
  mAppProperties.getUserSettings()->setValue("Preferences", xml);
 

The result : 


<?xml version="1.0" encoding="UTF-8"?>
<PROPERTIES>
  <VALUE name="Preferences" val="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;Settings&gt;&lt;MidiOutput0 name=&quot;LoopBe Internal MIDI&quot;/&gt;&lt;MidiOutput1/&gt;&lt;MidiOutput2/&gt;&lt;MidiOutput3/&gt;&lt;MidiOutput4 name=&quot;LoopBe Internal MIDI&quot;/&gt;&lt;MidiOutput5/&gt;&lt;MidiOutput6/&gt;&lt;MidiOutput7/&gt;&lt;Inputs&gt;&lt;FA-66MIDIIN/&gt;&lt;LoopBeInternalMIDI/&gt;&lt;NovationImpulse active=&quot;1&quot;/&gt;&lt;MIDIIN2(NovationImpulse)/&gt;&lt;MaschineMK2In/&gt;&lt;/Inputs&gt;&lt;/Settings&gt;"/>
  <VALUE name="Mappings">
    <KEYMAPPINGS basedOnDefaults="1"/>
  </VALUE>
</PROPERTIES>
 

Now, for the "Mappings" par I use the same kind of code and it works as expected.

The code :  


  ScopedPointer<XmlElement> xml( mKeyPressMappingSet.createXml(true) );
  mAppProperties.getUserSettings()->setValue("Mappings", xml);
 

The result (which can also be seen above) : 

  <VALUE name="Mappings">
    <KEYMAPPINGS basedOnDefaults="1"/>
  </VALUE>

Do you have an idea of what is wrong ?

 

P.S. : Using the latest tip 


#2

Not sure really - I'd only expect that to happen if the XML wasn't valid for some reason. If you can give me a piece of stand-alone test code I could use to replicate that, then I'll debug it..


#3

Actually, the problem came from MIDIIN2(NovationImpulse) . If I remove the (), it works fine.

 

There's an assertion in JUCE when you create an XmlElement : 


XmlElement::XmlElement (const String& tag) noexcept
    : tagName (tag)
{
    // the tag name mustn't be empty, or it'll look like a text element!
    jassert (tag.containsNonWhitespaceChars())
    // The tag can't contain spaces or other characters that would create invalid XML!
    jassert (! tag.containsAnyOf (" <>/&"));
}
 

but it doesn't catch () . 


#4

Thanks - I'll add that to the assertion..