Trying to fix a problem with the file import dialog. The dialog is not actually modal, so it's possible to close the plugin GUI or delete the plugin while the dialog is still open. No complete fix yet and the dialog opened by launchAsync has the ancient GUI style on Windows...Big SIGH.

This commit is contained in:
xenakios 2019-01-21 16:10:17 +02:00
parent 0dd0fb962e
commit 409c053057
4 changed files with 30 additions and 7 deletions

View File

@ -524,12 +524,14 @@ void PaulstretchpluginAudioProcessorEditor::chooseFile()
String filterstring = processor.m_afm->getWildcardForAllFormats();
//auto prevcomp = std::make_unique<AudioFilePreviewComponent>(&processor);
//processor.setAudioPreview(prevcomp.get());
FileChooser myChooser("Please select audio file...",
m_filechooser = std::make_unique<FileChooser>("Please select audio file...",
initialloc,
filterstring,true);
if (myChooser.browseForFileToOpen())
filterstring,true,false,this);
m_filechooser->launchAsync(0, processor.m_filechoose_callback);
return;
//if (m_filechooser->launchAsync(0,processor.m_filechoose_callback))
{
File resu = myChooser.getResult();
File resu = m_filechooser->getResult();
String pathname = resu.getFullPathName();
if (pathname.startsWith("/localhost"))
{
@ -539,8 +541,8 @@ void PaulstretchpluginAudioProcessorEditor::chooseFile()
processor.m_propsfile->m_props_file->setValue("importfilefolder", resu.getParentDirectory().getFullPathName());
m_last_err = processor.setAudioFile(resu);
}
processor.setAudioPreview(nullptr);
toFront(true);
//processor.setAudioPreview(nullptr);
//toFront(true);
}
void PaulstretchpluginAudioProcessorEditor::showSettingsMenu()

View File

@ -436,6 +436,7 @@ public:
void showRenderDialog();
void executeModalMenuAction(int menuid, int actionid);
SimpleFFTComponent m_sonogram;
String m_last_err;
private:
PaulstretchpluginAudioProcessor& processor;
uptrvec<ParameterComponent> m_parcomps;
@ -449,7 +450,7 @@ private:
SpectralChainEditor m_spec_order_ed;
void showSettingsMenu();
String m_last_err;
zoom_scrollbar m_zs;
RatioMixerEditor m_ratiomixeditor{ 8 };
FreeFilterComponent m_free_filter_component;
@ -458,6 +459,8 @@ private:
Component* m_wave_container=nullptr;
void showAbout();
std::vector<int> m_capturelens{ 2,5,10,30,60,120 };
std::unique_ptr<FileChooser> m_filechooser;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessorEditor)
};

View File

@ -60,6 +60,23 @@ inline AudioParameterFloat* make_floatpar(String id, String name, float minv, fl
PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
: m_bufferingthread("pspluginprebufferthread")
{
m_filechoose_callback = [this](const FileChooser& chooser)
{
File resu = chooser.getResult();
String pathname = resu.getFullPathName();
if (pathname.startsWith("/localhost"))
{
pathname = pathname.substring(10);
resu = File(pathname);
}
m_propsfile->m_props_file->setValue("importfilefolder", resu.getParentDirectory().getFullPathName());
String loaderr = setAudioFile(resu);
if (auto ed = dynamic_cast<PaulstretchpluginAudioProcessorEditor*>(getActiveEditor()); ed != nullptr)
{
ed->m_last_err = loaderr;
}
};
m_playposinfo.timeInSeconds = 0.0;
m_free_filter_envelope = std::make_shared<breakpoint_envelope>();

View File

@ -241,6 +241,7 @@ public:
bool m_save_captured_audio = true;
String m_capture_location;
bool m_midinote_control = false;
std::function<void(const FileChooser&)> m_filechoose_callback;
private:
bool m_prebuffering_inited = false;
AudioBuffer<float> m_recbuffer;