1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-06 04:00:08 +00:00

Made a lot of ScopedPointer usage conform to the std::unique_ptr interface

This commit is contained in:
Tom Poole 2018-04-10 14:50:25 +01:00
parent 2d9fc46b4e
commit 4229dc0a4f
99 changed files with 6809 additions and 498 deletions

View file

@ -129,7 +129,7 @@ public:
oldIndex (-1)
{
if (ComponentTypeHandler* const h = ComponentTypeHandler::getHandlerFor (*comp))
xml = h->createXmlFor (comp, &layout);
xml.reset (h->createXmlFor (comp, &layout));
else
jassertfalse;
@ -415,18 +415,17 @@ Component* ComponentLayout::addNewComponent (ComponentTypeHandler* const type, i
{
c->setSize (type->getDefaultWidth(), type->getDefaultHeight());
c->setCentrePosition (x, y);
updateStoredComponentPosition (c, false);
updateStoredComponentPosition (c.get(), false);
c->getProperties().set ("id", nextCompUID++);
ScopedPointer<XmlElement> xml (type->createXmlFor (c, this));
c.reset();
c = addComponentFromXml (*xml, true);
ScopedPointer<XmlElement> xml (type->createXmlFor (c.get(), this));
c.reset (addComponentFromXml (*xml, true));
String memberName (CodeHelpers::makeValidIdentifier (type->getClassName (c), true, true, false));
setComponentMemberVariableName (c, memberName);
String memberName (CodeHelpers::makeValidIdentifier (type->getClassName (c.get()), true, true, false));
setComponentMemberVariableName (c.get(), memberName);
selected.selectOnly (c);
selected.selectOnly (c.get());
}
return c.release();
@ -447,16 +446,16 @@ Component* ComponentLayout::addComponentFromXml (const XmlElement& xml, const bo
{
ScopedPointer<Component> newComp (type->createNewComponent (getDocument()));
if (type->restoreFromXml (xml, newComp, this))
if (type->restoreFromXml (xml, newComp.get(), this))
{
// ensure that the new comp's name is unique
setComponentMemberVariableName (newComp, getComponentMemberVariableName (newComp));
setComponentMemberVariableName (newComp.get(), getComponentMemberVariableName (newComp.get()));
// check for duped IDs..
while (findComponentWithId (ComponentTypeHandler::getComponentId (newComp)) != nullptr)
ComponentTypeHandler::setComponentId (newComp, Random::getSystemRandom().nextInt64());
while (findComponentWithId (ComponentTypeHandler::getComponentId (newComp.get())) != nullptr)
ComponentTypeHandler::setComponentId (newComp.get(), Random::getSystemRandom().nextInt64());
components.add (newComp);
components.add (newComp.get());
changed();
return newComp.release();
}