Skip to content

Commit

Permalink
- fix compiing scripts only saving currently edited file
Browse files Browse the repository at this point in the history
- fix compiling all scripts not saving any edited files
  • Loading branch information
christoph-hart committed Oct 7, 2024
1 parent cc52289 commit 0017547
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 28 deletions.
2 changes: 1 addition & 1 deletion currentGitHash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ee19fcc0670facfdd2d34384291d3e7b1516cf8b
cc52289596f83b98fa709b1e257170bf080c7fdd
2 changes: 1 addition & 1 deletion hi_backend/backend/currentGit.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define PREVIOUS_HISE_COMMIT "ee19fcc0670facfdd2d34384291d3e7b1516cf8b"
#define PREVIOUS_HISE_COMMIT "cc52289596f83b98fa709b1e257170bf080c7fdd"
32 changes: 32 additions & 0 deletions hi_core/hi_core/GlobalScriptCompileBroadcaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,22 @@ void GlobalScriptCompileBroadcaster::setWebViewRoot(File newRoot)
webViewRoot = newRoot;
}

void GlobalScriptCompileBroadcaster::saveAllExternalFiles()
{
for(int i = 0; i < getNumExternalScriptFiles(); i++)
{
auto ef = getExternalScriptFile(i);

if(ef->getResourceType() == ExternalScriptFile::ResourceType::EmbeddedInSnippet)
{
debugToConsole(dynamic_cast<MainController*>(this)->getMainSynthChain(), "Skip writing embedded file " + ef->getFile().getFileName() + " to disk...");
continue;
}

ef->saveFile();
}
}


void GlobalScriptCompileBroadcaster::sendScriptCompileMessage(JavascriptProcessor *processorThatWasCompiled)
{
Expand Down Expand Up @@ -522,4 +538,20 @@ File ExternalScriptFile::getFile() const

ExternalScriptFile::RuntimeError::Broadcaster& ExternalScriptFile::getRuntimeErrorBroadcaster()
{ return runtimeErrorBroadcaster; }

bool ExternalScriptFile::extractEmbedded()
{
if(resourceType == ResourceType::EmbeddedInSnippet)
{
if(!file.existsAsFile() || PresetHandler::showYesNoWindow("Overwrite local file", "The file " + getFile().getFileName() + " from the snippet already exists. Do you want to overwrite your local file?"))
{
file.getParentDirectory().createDirectory();
file.replaceWithText(content.getAllContent());
resourceType = ResourceType::FileBased;
return true;
}
}

return false;
}
} // namespace hise
18 changes: 3 additions & 15 deletions hi_core/hi_core/GlobalScriptCompileBroadcaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,7 @@ class ExternalScriptFile : public ReferenceCountedObject
return resourceType;
}

bool extractEmbedded()
{
if(resourceType == ResourceType::EmbeddedInSnippet)
{
if(!file.existsAsFile() || PresetHandler::showYesNoWindow("Overwrite local file", "The file " + getFile().getFileName() + " from the snippet already exists. Do you want to overwrite your local file?"))
{
file.getParentDirectory().createDirectory();
file.replaceWithText(content.getAllContent());
resourceType = ResourceType::FileBased;
return true;
}
}

return false;
}
bool extractEmbedded();

private:

Expand Down Expand Up @@ -294,6 +280,8 @@ class GlobalScriptCompileBroadcaster

void setWebViewRoot(File newRoot);

void saveAllExternalFiles();

private:

File webViewRoot;
Expand Down
2 changes: 2 additions & 0 deletions hi_core/hi_core/MainController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ void MainController::compileAllScripts()
JavascriptProcessor *sp;

Processor* first = nullptr;

saveAllExternalFiles();

while((sp = it.getNextProcessor()) != nullptr)
{
Expand Down
13 changes: 2 additions & 11 deletions hi_scripting/scripting/components/PopupEditors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,17 +607,8 @@ File PopupIncludeEditor::getFile() const

void PopupIncludeEditor::compileInternal()
{
if (externalFile != nullptr)
{
if(externalFile->getResourceType() == ExternalScriptFile::ResourceType::EmbeddedInSnippet)
{
debugToConsole(dynamic_cast<Processor*>(getScriptProcessor()), "Skip writing embedded file " + externalFile->getFile().getFileName() + " to disk...");
}
else
{
externalFile->saveFile();
}
}
auto mc = dynamic_cast<Processor*>(getScriptProcessor())->getMainController();
mc->saveAllExternalFiles();

if(t == FileTypes::CSS)
{
Expand Down

0 comments on commit 0017547

Please sign in to comment.