diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 0ae62b0..94f0b49 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -136,16 +136,18 @@ void OscirenderAudioProcessorEditor::fileUpdated(juce::File file) { obj.setVisible(true); } } - + +// parsersLock must be locked before calling this function void OscirenderAudioProcessorEditor::codeDocumentTextInserted(const juce::String& newText, int insertIndex) { - juce::SpinLock::ScopedLockType lock(audioProcessor.parsersLock); - int index = audioProcessor.getCurrentFileIndex(); - juce::String file = codeDocuments[index]->getAllContent(); - audioProcessor.updateFileBlock(index, std::make_shared(file.toRawUTF8(), file.getNumBytesAsUTF8() + 1)); + updateCodeDocument(); } +// parsersLock must be locked before calling this function void OscirenderAudioProcessorEditor::codeDocumentTextDeleted(int startIndex, int endIndex) { - juce::SpinLock::ScopedLockType lock(audioProcessor.parsersLock); + updateCodeDocument(); +} + +void OscirenderAudioProcessorEditor::updateCodeDocument() { int index = audioProcessor.getCurrentFileIndex(); juce::String file = codeDocuments[index]->getAllContent(); audioProcessor.updateFileBlock(index, std::make_shared(file.toRawUTF8(), file.getNumBytesAsUTF8() + 1)); diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 85f3ff1..32eafcc 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -47,6 +47,7 @@ private: void codeDocumentTextInserted(const juce::String& newText, int insertIndex) override; void codeDocumentTextDeleted(int startIndex, int endIndex) override; + void updateCodeDocument(); bool keyPressed(const juce::KeyPress& key) override;