1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Projucer: Synchronise access to EnabledModuleList state

This commit is contained in:
ed 2020-07-10 17:46:27 +01:00
parent 94d853b00d
commit 3de4fab219
2 changed files with 21 additions and 4 deletions

View file

@ -411,6 +411,8 @@ void EnabledModulesList::sortAlphabetically()
};
ModuleTreeSorter sorter;
const ScopedLock sl (stateLock);
state.sort (sorter, getUndoManager(), false);
}
@ -439,6 +441,7 @@ ModuleDescription EnabledModulesList::getModuleInfo (const String& moduleID) con
bool EnabledModulesList::isModuleEnabled (const String& moduleID) const
{
const ScopedLock sl (stateLock);
return state.getChildWithProperty (Ids::ID, moduleID).isValid();
}
@ -502,11 +505,13 @@ bool EnabledModulesList::doesModuleHaveHigherCppStandardThanProject (const Strin
bool EnabledModulesList::shouldUseGlobalPath (const String& moduleID) const
{
const ScopedLock sl (stateLock);
return (bool) shouldUseGlobalPathValue (moduleID).getValue();
}
Value EnabledModulesList::shouldUseGlobalPathValue (const String& moduleID) const
{
const ScopedLock sl (stateLock);
return state.getChildWithProperty (Ids::ID, moduleID)
.getPropertyAsValue (Ids::useGlobalPath, getUndoManager());
}
@ -518,6 +523,7 @@ bool EnabledModulesList::shouldShowAllModuleFilesInProject (const String& module
Value EnabledModulesList::shouldShowAllModuleFilesInProjectValue (const String& moduleID) const
{
const ScopedLock sl (stateLock);
return state.getChildWithProperty (Ids::ID, moduleID)
.getPropertyAsValue (Ids::showAllCode, getUndoManager());
}
@ -529,6 +535,7 @@ bool EnabledModulesList::shouldCopyModuleFilesLocally (const String& moduleID) c
Value EnabledModulesList::shouldCopyModuleFilesLocallyValue (const String& moduleID) const
{
const ScopedLock sl (stateLock);
return state.getChildWithProperty (Ids::ID, moduleID)
.getPropertyAsValue (Ids::useLocalCopy, getUndoManager());
}
@ -616,7 +623,11 @@ void EnabledModulesList::addModule (const File& moduleFolder, bool copyLocally,
ValueTree module (Ids::MODULE);
module.setProperty (Ids::ID, moduleID, getUndoManager());
state.appendChild (module, getUndoManager());
{
const ScopedLock sl (stateLock);
state.appendChild (module, getUndoManager());
}
sortAlphabetically();
shouldShowAllModuleFilesInProjectValue (moduleID) = true;
@ -686,9 +697,13 @@ void EnabledModulesList::addModuleOfferingToCopy (const File& f, bool isFromUser
void EnabledModulesList::removeModule (String moduleID) // must be pass-by-value, and not a const ref!
{
for (auto i = state.getNumChildren(); --i >= 0;)
if (state.getChild(i) [Ids::ID] == moduleID)
state.removeChild (i, getUndoManager());
{
const ScopedLock sl (stateLock);
for (auto i = state.getNumChildren(); --i >= 0;)
if (state.getChild(i) [Ids::ID] == moduleID)
state.removeChild (i, getUndoManager());
}
for (Project::ExporterIterator exporter (project); exporter.next();)
exporter->removePathForModule (moduleID);