@@ -84,7 +84,7 @@ struct BackgroundLogo : public AnimatedContent | |||||
</svg> | </svg> | ||||
)blahblah"; | )blahblah"; | ||||
logo.reset (Drawable::createFromSVG (*parseXML (logoData))); | |||||
logo = Drawable::createFromSVG (*parseXML (logoData)); | |||||
} | } | ||||
String getName() const override { return "Background Image"; } | String getName() const override { return "Background Image"; } | ||||
@@ -429,14 +429,13 @@ private: | |||||
{ | { | ||||
auto liveModules = project.getProjectRoot().getChildWithName (Ids::MODULES); | auto liveModules = project.getProjectRoot().getChildWithName (Ids::MODULES); | ||||
auto xml = parseXML (project.getFile()); | |||||
if (xml == nullptr || ! xml->hasTagName (Ids::JUCERPROJECT.toString())) | |||||
return false; | |||||
auto diskModules = ValueTree::fromXml (*xml).getChildWithName (Ids::MODULES); | |||||
if (auto xml = parseXMLIfTagMatches (project.getFile(), Ids::JUCERPROJECT.toString())) | |||||
{ | |||||
auto diskModules = ValueTree::fromXml (*xml).getChildWithName (Ids::MODULES); | |||||
return liveModules.isEquivalentTo (diskModules); | |||||
} | |||||
return liveModules.isEquivalentTo (diskModules); | |||||
return false; | |||||
} | } | ||||
static bool areAnyModulesMissing (Project& project) | static bool areAnyModulesMissing (Project& project) | ||||
@@ -575,9 +575,9 @@ static void forgetRecentFile (const File& file) | |||||
//============================================================================== | //============================================================================== | ||||
Result Project::loadDocument (const File& file) | Result Project::loadDocument (const File& file) | ||||
{ | { | ||||
auto xml = parseXML (file); | |||||
auto xml = parseXMLIfTagMatches (file, Ids::JUCERPROJECT.toString()); | |||||
if (xml == nullptr || ! xml->hasTagName (Ids::JUCERPROJECT.toString())) | |||||
if (xml == nullptr) | |||||
return Result::fail ("Not a valid Jucer project!"); | return Result::fail ("Not a valid Jucer project!"); | ||||
auto newTree = ValueTree::fromXml (*xml); | auto newTree = ValueTree::fromXml (*xml); | ||||
@@ -1239,7 +1239,7 @@ std::unique_ptr<Drawable> Project::Item::loadAsImageFile() const | |||||
return nullptr; | return nullptr; | ||||
if (isValid()) | if (isValid()) | ||||
return std::unique_ptr<Drawable> (Drawable::createFromImageFile (getFile())); | |||||
return Drawable::createFromImageFile (getFile()); | |||||
return {}; | return {}; | ||||
} | } | ||||
@@ -153,13 +153,9 @@ StringArray AppearanceSettings::getColourNames() const | |||||
{ | { | ||||
StringArray s; | StringArray s; | ||||
for (int i = 0; i < settings.getNumChildren(); ++i) | |||||
{ | |||||
const ValueTree c (settings.getChild(i)); | |||||
for (auto c : settings) | |||||
if (c.hasType ("COLOUR")) | if (c.hasType ("COLOUR")) | ||||
s.add (c [Ids::name]); | |||||
} | |||||
s.add (c[Ids::name]); | |||||
return s; | return s; | ||||
} | } | ||||
@@ -32,19 +32,16 @@ namespace juce | |||||
e.g. | e.g. | ||||
@code | @code | ||||
XmlDocument myDocument (File ("myfile.xml")); | XmlDocument myDocument (File ("myfile.xml")); | ||||
std::unique_ptr<XmlElement> mainElement (myDocument.getDocumentElement()); | |||||
if (mainElement == nullptr) | |||||
if (auto mainElement = myDocument.getDocumentElement()) | |||||
{ | { | ||||
String error = myDocument.getLastParseError(); | |||||
..use the element | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
..use the element | |||||
String error = myDocument.getLastParseError(); | |||||
} | } | ||||
@endcode | @endcode | ||||
Or you can use the helper functions for much less verbose parsing.. | Or you can use the helper functions for much less verbose parsing.. | ||||
@@ -296,7 +296,7 @@ std::unique_ptr<Drawable> JUCESplashScreen::getSplashScreenLogo() | |||||
auto svgXml = parseXML (svgData); | auto svgXml = parseXML (svgData); | ||||
jassert (svgXml != nullptr); | jassert (svgXml != nullptr); | ||||
return std::unique_ptr<Drawable> (Drawable::createFromSVG (*svgXml)); | |||||
return Drawable::createFromSVG (*svgXml); | |||||
} | } | ||||
void JUCESplashScreen::paint (Graphics& g) | void JUCESplashScreen::paint (Graphics& g) | ||||
@@ -436,32 +436,29 @@ String TableHeaderComponent::toString() const | |||||
void TableHeaderComponent::restoreFromString (const String& storedVersion) | void TableHeaderComponent::restoreFromString (const String& storedVersion) | ||||
{ | { | ||||
if (auto storedXML = parseXML (storedVersion)) | |||||
if (auto storedXML = parseXMLIfTagMatches (storedVersion, "TABLELAYOUT")) | |||||
{ | { | ||||
if (storedXML->hasTagName ("TABLELAYOUT")) | |||||
int index = 0; | |||||
forEachXmlChildElement (*storedXML, col) | |||||
{ | { | ||||
int index = 0; | |||||
auto tabId = col->getIntAttribute ("id"); | |||||
forEachXmlChildElement (*storedXML, col) | |||||
if (auto* ci = getInfoForId (tabId)) | |||||
{ | { | ||||
auto tabId = col->getIntAttribute ("id"); | |||||
if (auto* ci = getInfoForId (tabId)) | |||||
{ | |||||
columns.move (columns.indexOf (ci), index); | |||||
ci->width = col->getIntAttribute ("width"); | |||||
setColumnVisible (tabId, col->getBoolAttribute ("visible")); | |||||
} | |||||
++index; | |||||
columns.move (columns.indexOf (ci), index); | |||||
ci->width = col->getIntAttribute ("width"); | |||||
setColumnVisible (tabId, col->getBoolAttribute ("visible")); | |||||
} | } | ||||
columnsResized = true; | |||||
sendColumnsChanged(); | |||||
setSortColumnId (storedXML->getIntAttribute ("sortedCol"), | |||||
storedXML->getBoolAttribute ("sortForwards", true)); | |||||
++index; | |||||
} | } | ||||
columnsResized = true; | |||||
sendColumnsChanged(); | |||||
setSortColumnId (storedXML->getIntAttribute ("sortedCol"), | |||||
storedXML->getBoolAttribute ("sortForwards", true)); | |||||
} | } | ||||
} | } | ||||
@@ -610,13 +610,13 @@ static void addAllSelectedItemIds (TreeViewItem* item, XmlElement& parent) | |||||
addAllSelectedItemIds (item->getSubItem(i), parent); | addAllSelectedItemIds (item->getSubItem(i), parent); | ||||
} | } | ||||
std::unique_ptr<XmlElement> TreeView::getOpennessState (const bool alsoIncludeScrollPosition) const | |||||
std::unique_ptr<XmlElement> TreeView::getOpennessState (bool alsoIncludeScrollPosition) const | |||||
{ | { | ||||
XmlElement* e = nullptr; | |||||
std::unique_ptr<XmlElement> e; | |||||
if (rootItem != nullptr) | if (rootItem != nullptr) | ||||
{ | { | ||||
e = rootItem->getOpennessState (false); | |||||
e.reset (rootItem->getOpennessState (false)); | |||||
if (e != nullptr) | if (e != nullptr) | ||||
{ | { | ||||
@@ -627,7 +627,7 @@ std::unique_ptr<XmlElement> TreeView::getOpennessState (const bool alsoIncludeSc | |||||
} | } | ||||
} | } | ||||
return std::unique_ptr<XmlElement> (e); | |||||
return e; | |||||
} | } | ||||
void TreeView::restoreOpennessState (const XmlElement& newState, const bool restoreStoredSelection) | void TreeView::restoreOpennessState (const XmlElement& newState, const bool restoreStoredSelection) | ||||
@@ -1863,7 +1863,7 @@ std::unique_ptr<XmlElement> TreeViewItem::getOpennessState() const | |||||
return std::unique_ptr<XmlElement> (getOpennessState (true)); | return std::unique_ptr<XmlElement> (getOpennessState (true)); | ||||
} | } | ||||
XmlElement* TreeViewItem::getOpennessState (const bool canReturnNull) const | |||||
XmlElement* TreeViewItem::getOpennessState (bool canReturnNull) const | |||||
{ | { | ||||
auto name = getUniqueName(); | auto name = getUniqueName(); | ||||