Skip to content

Commit

Permalink
Don't attempt to save non-existent external script files (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhealey authored Dec 8, 2024
1 parent 50ed899 commit d890255
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion hi_core/hi_core/GlobalScriptCompileBroadcaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ void GlobalScriptCompileBroadcaster::clearIncludedFiles()
includedFiles.clear();
}

void GlobalScriptCompileBroadcaster::removeIncludedFile(int index)
{
includedFiles.remove(index);
}

void GlobalScriptCompileBroadcaster::restoreIncludedScriptFilesFromSnippet(const ValueTree& snippetTree)
{
#if USE_BACKEND
Expand Down Expand Up @@ -217,9 +222,15 @@ void GlobalScriptCompileBroadcaster::setWebViewRoot(File newRoot)
void GlobalScriptCompileBroadcaster::saveAllExternalFiles()
{
for(int i = 0; i < getNumExternalScriptFiles(); i++)
{
{
auto ef = getExternalScriptFile(i);

if (!ef->getFile().exists())
{
removeIncludedFile(i);
continue;
}

if(ef->getResourceType() == ExternalScriptFile::ResourceType::EmbeddedInSnippet)
{
debugToConsole(dynamic_cast<MainController*>(this)->getMainSynthChain(), "Skip writing embedded file " + ef->getFile().getFileName() + " to disk...");
Expand Down
1 change: 1 addition & 0 deletions hi_core/hi_core/GlobalScriptCompileBroadcaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class GlobalScriptCompileBroadcaster
ExternalScriptFile::Ptr getExternalScriptFile(int index) const;

void clearIncludedFiles();
void removeIncludedFile(int index);

void restoreIncludedScriptFilesFromSnippet(const ValueTree& snippetTree);

Expand Down

1 comment on commit d890255

@davidhealey
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible this breaks embedded files in snippets?

Please sign in to comment.