Skip to content

Commit

Permalink
- fix crash when opening HISE with a unloaded CSS file reference
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-hart committed Sep 30, 2024
1 parent 08a7dac commit 35da98a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion currentGitHash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
575e7e2bb646d973ef0f257acae98ffd02526038
08a7dac9e7d0bea920fd7d3bf7b36ae23ac8f1e0
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 "575e7e2bb646d973ef0f257acae98ffd02526038"
#define PREVIOUS_HISE_COMMIT "08a7dac9e7d0bea920fd7d3bf7b36ae23ac8f1e0"
10 changes: 10 additions & 0 deletions hi_backend/backend/debug_components/FileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,12 @@ void FileBrowser::previewFile(const File& f)
auto c = new mcl::XmlEditor(f);
content = c;
}
else if (ff->isCSSFile(f))
{
auto c = new mcl::XmlEditor(f);
content = c;
c->editor.editor.setLanguageManager(new simple_css::LanguageManager(c->editor.editor.getTextDocument()));
}
else if (ff->isAudioFile(f))
{
auto c = new AudioPreviewComponent(rootWindow->getBackendProcessor(), f);
Expand Down Expand Up @@ -883,6 +889,10 @@ void FileBrowser::mouseDoubleClick(const MouseEvent& )
rw->getMainPanel()->loadNewContainer(newRoot);
}
else if (newRoot.getFileExtension() == ".xml")
{
previewFile(newRoot);
}
else if (newRoot.getFileExtension() == ".css")
{
previewFile(newRoot);
}
Expand Down
9 changes: 7 additions & 2 deletions hi_backend/backend/debug_components/FileBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class FileBrowser : public Component,
file.getFileName() == "LinkOSX" ||
#endif
isAudioFile(file) || isImageFile(file) || isXmlFile(file) ||
isScriptFile(file) || isUserPresetFile(file) || isMidiFile(file);
isScriptFile(file) || isUserPresetFile(file) || isMidiFile(file) || isCSSFile(file);
}

bool isImageFile(const File& file) const
Expand All @@ -288,7 +288,12 @@ class FileBrowser : public Component,
{
return file.hasFileExtension("mid");
}


bool isCSSFile(const File& file) const
{
return file.hasFileExtension("css");
}

bool isXmlFile(const File& file) const
{
return file.hasFileExtension("xml");
Expand Down
2 changes: 1 addition & 1 deletion hi_scripting/scripting/components/PopupEditors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ PopupIncludeEditor::PopupIncludeEditor(JavascriptProcessor *s, const File &fileT


Processor *p = dynamic_cast<Processor*>(jp.get());
externalFile = p->getMainController()->getExternalScriptFile(fileToEdit, t == FileTypes::Javascript);
externalFile = p->getMainController()->getExternalScriptFile(fileToEdit, t == FileTypes::Javascript || t == FileTypes::CSS);

p->getMainController()->addScriptListener(this);

Expand Down
3 changes: 3 additions & 0 deletions hi_tools/simple_css/LanguageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ void LanguageManager::CssTokens::addTokens(mcl::TokenCollection::List& tokens)

void LanguageManager::setupEditor(mcl::TextEditor* editor)
{
if(editor->tokenCollection == nullptr)
editor->tokenCollection = new mcl::TokenCollection("CSS");

addTokenProviders(editor->tokenCollection.get());
}

Expand Down

0 comments on commit 35da98a

Please sign in to comment.