I’m having a strange issue in which I use performExternalDragDropOfFiles() within a mouseDrag(). This works just fine every time.
However, if I launch a juce::FileBrowserComponent, and then proceed to drag out the file after using and closing it, Ableton crashes. This isn’t limited to just the juce::FileBrowserComponent either, as if I have a PopUpMenu with sub PopUpMenu’s inside of it, it will also crash after the sub menu has been shown. So it appears only certain situations will trigger the crash after certain components have been shown.
I created a very simple example project to eliminate if it was anything within my code that was causing it but still ran into the same issue with a bare bones project with just a file chooser and a drag out component using .wav from my desktop.
This only appears to be happening on Windows 10 (and tested in 11) with Ableton 11 and Ableton 12. I have tried many ways to come up with a work around to prevent the crash, but have had no success.
Has anyone else experienced this issue, or have any ideas on how to fix this?
// How the file chooser is created:
void TestDragAudioProcessorEditor::buttonClicked(juce::Button* button)
{
chooser = std::make_unique<juce::FileChooser>("Select a .wav file", juce::File{}, "*.wav");
auto chooserFlags = juce::FileBrowserComponent::openMode | juce::FileBrowserComponent::canSelectFiles;
chooser->launchAsync(chooserFlags, [](const juce::FileChooser& fc)
{
//Do nothing, here for testing purposes
});
}
// For the mouse drag of a component:
void DraggableComponent::mouseDrag(const juce::MouseEvent& e)
{
juce::File testFile("C:\\Users\Tensorpunk\\Desktop\\test.wav");
if (testFile.existsAsFile())
{
juce::StringArray files;
files.add(testFile.getFullPathName());
auto editor = findParentComponentOfClass<TestDragAudioProcessorEditor>();
juce::Point<int> mousePosition = e.getScreenPosition();
juce::Rectangle<int> windowBounds = editor->getScreenBounds();
if (!windowBounds.contains(mousePosition))
{
// Crash happens after this has been called after the chooser has been shown once, otherwise works perfectly fine
performExternalDragDropOfFiles(files, true, this);
}
}
}