Prevent double-locking when using code editor

pull/170/head
James Ball 2023-07-04 20:59:47 +01:00
rodzic b5cfc2824b
commit a487306784
2 zmienionych plików z 9 dodań i 6 usunięć

Wyświetl plik

@ -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<juce::MemoryBlock>(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<juce::MemoryBlock>(file.toRawUTF8(), file.getNumBytesAsUTF8() + 1));

Wyświetl plik

@ -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;