mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
A few more internal updates for better smart pointer use
This commit is contained in:
parent
49fa0f73e4
commit
c6d1828a32
8 changed files with 39 additions and 50 deletions
|
|
@ -84,7 +84,7 @@ struct BackgroundLogo : public AnimatedContent
|
|||
</svg>
|
||||
)blahblah";
|
||||
|
||||
logo.reset (Drawable::createFromSVG (*parseXML (logoData)));
|
||||
logo = Drawable::createFromSVG (*parseXML (logoData));
|
||||
}
|
||||
|
||||
String getName() const override { return "Background Image"; }
|
||||
|
|
|
|||
|
|
@ -429,14 +429,13 @@ private:
|
|||
{
|
||||
auto liveModules = project.getProjectRoot().getChildWithName (Ids::MODULES);
|
||||
|
||||
auto xml = parseXML (project.getFile());
|
||||
if (auto xml = parseXMLIfTagMatches (project.getFile(), Ids::JUCERPROJECT.toString()))
|
||||
{
|
||||
auto diskModules = ValueTree::fromXml (*xml).getChildWithName (Ids::MODULES);
|
||||
return liveModules.isEquivalentTo (diskModules);
|
||||
}
|
||||
|
||||
if (xml == nullptr || ! xml->hasTagName (Ids::JUCERPROJECT.toString()))
|
||||
return false;
|
||||
|
||||
auto diskModules = ValueTree::fromXml (*xml).getChildWithName (Ids::MODULES);
|
||||
|
||||
return liveModules.isEquivalentTo (diskModules);
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool areAnyModulesMissing (Project& project)
|
||||
|
|
|
|||
|
|
@ -575,9 +575,9 @@ static void forgetRecentFile (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!");
|
||||
|
||||
auto newTree = ValueTree::fromXml (*xml);
|
||||
|
|
@ -1239,7 +1239,7 @@ std::unique_ptr<Drawable> Project::Item::loadAsImageFile() const
|
|||
return nullptr;
|
||||
|
||||
if (isValid())
|
||||
return std::unique_ptr<Drawable> (Drawable::createFromImageFile (getFile()));
|
||||
return Drawable::createFromImageFile (getFile());
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,13 +153,9 @@ StringArray AppearanceSettings::getColourNames() const
|
|||
{
|
||||
StringArray s;
|
||||
|
||||
for (int i = 0; i < settings.getNumChildren(); ++i)
|
||||
{
|
||||
const ValueTree c (settings.getChild(i));
|
||||
|
||||
for (auto c : settings)
|
||||
if (c.hasType ("COLOUR"))
|
||||
s.add (c [Ids::name]);
|
||||
}
|
||||
s.add (c[Ids::name]);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,19 +32,16 @@ namespace juce
|
|||
|
||||
e.g.
|
||||
@code
|
||||
|
||||
XmlDocument myDocument (File ("myfile.xml"));
|
||||
std::unique_ptr<XmlElement> mainElement (myDocument.getDocumentElement());
|
||||
|
||||
if (mainElement == nullptr)
|
||||
{
|
||||
String error = myDocument.getLastParseError();
|
||||
}
|
||||
else
|
||||
if (auto mainElement = myDocument.getDocumentElement())
|
||||
{
|
||||
..use the element
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
String error = myDocument.getLastParseError();
|
||||
}
|
||||
@endcode
|
||||
|
||||
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);
|
||||
jassert (svgXml != nullptr);
|
||||
return std::unique_ptr<Drawable> (Drawable::createFromSVG (*svgXml));
|
||||
return Drawable::createFromSVG (*svgXml);
|
||||
}
|
||||
|
||||
void JUCESplashScreen::paint (Graphics& g)
|
||||
|
|
|
|||
|
|
@ -436,32 +436,29 @@ String TableHeaderComponent::toString() const
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
e = rootItem->getOpennessState (false);
|
||||
e.reset (rootItem->getOpennessState (false));
|
||||
|
||||
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)
|
||||
|
|
@ -1863,7 +1863,7 @@ std::unique_ptr<XmlElement> TreeViewItem::getOpennessState() const
|
|||
return std::unique_ptr<XmlElement> (getOpennessState (true));
|
||||
}
|
||||
|
||||
XmlElement* TreeViewItem::getOpennessState (const bool canReturnNull) const
|
||||
XmlElement* TreeViewItem::getOpennessState (bool canReturnNull) const
|
||||
{
|
||||
auto name = getUniqueName();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue