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

Projucer: Avoid adding duplicate arrays to plist

Merging a plist which contained UIBackgroundModes or
UISupportedInterfaceOrientations keys could result in these keys being
duplicated in the generated plist.

This patch will avoid adding a new array if the array's key already
exists in the plist.
This commit is contained in:
reuk 2021-08-09 11:56:56 +01:00
parent 65bd869451
commit bde242892f
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -28,22 +28,28 @@ namespace juce
namespace build_tools
{
//==============================================================================
static bool keyFoundAndNotSequentialDuplicate (XmlElement& xml, const String& key)
static XmlElement* getKeyWithName (XmlElement& xml, const String& key)
{
for (auto* element : xml.getChildWithTagNameIterator ("key"))
{
if (element->getAllSubText().trim().equalsIgnoreCase (key))
{
if (element->getNextElement() != nullptr && element->getNextElement()->hasTagName ("key"))
{
// found broken plist format (sequential duplicate), fix by removing
xml.removeChildElement (element, true);
return false;
}
return element;
// key found (not sequential duplicate)
return true;
return nullptr;
}
static bool keyFoundAndNotSequentialDuplicate (XmlElement& xml, const String& key)
{
if (auto* element = getKeyWithName (xml, key))
{
if (element->getNextElement() != nullptr && element->getNextElement()->hasTagName ("key"))
{
// found broken plist format (sequential duplicate), fix by removing
xml.removeChildElement (element, true);
return false;
}
// key found (not sequential duplicate)
return true;
}
// key not found
@ -87,6 +93,9 @@ namespace build_tools
static void addArrayToPlist (XmlElement& dict, String arrayKey, const StringArray& arrayElements)
{
if (getKeyWithName (dict, arrayKey) != nullptr)
return;
dict.createNewChildElement ("key")->addTextElement (arrayKey);
auto* plistStringArray = dict.createNewChildElement ("array");