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:
parent
65bd869451
commit
bde242892f
1 changed files with 20 additions and 11 deletions
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue