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

View File

@ -436,6 +436,7 @@ public:
void showRenderDialog(); void showRenderDialog();
void executeModalMenuAction(int menuid, int actionid); void executeModalMenuAction(int menuid, int actionid);
SimpleFFTComponent m_sonogram; SimpleFFTComponent m_sonogram;
String m_last_err;
private: private:
PaulstretchpluginAudioProcessor& processor; PaulstretchpluginAudioProcessor& processor;
uptrvec<ParameterComponent> m_parcomps; uptrvec<ParameterComponent> m_parcomps;
@ -449,7 +450,7 @@ private:
SpectralChainEditor m_spec_order_ed; SpectralChainEditor m_spec_order_ed;
void showSettingsMenu(); void showSettingsMenu();
String m_last_err;
zoom_scrollbar m_zs; zoom_scrollbar m_zs;
RatioMixerEditor m_ratiomixeditor{ 8 }; RatioMixerEditor m_ratiomixeditor{ 8 };
FreeFilterComponent m_free_filter_component; FreeFilterComponent m_free_filter_component;
@ -458,6 +459,8 @@ private:
Component* m_wave_container=nullptr; Component* m_wave_container=nullptr;
void showAbout(); void showAbout();
std::vector<int> m_capturelens{ 2,5,10,30,60,120 }; 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) 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() PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
: m_bufferingthread("pspluginprebufferthread") : 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_playposinfo.timeInSeconds = 0.0;
m_free_filter_envelope = std::make_shared<breakpoint_envelope>(); m_free_filter_envelope = std::make_shared<breakpoint_envelope>();

View File

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