mirror of https://github.com/odrling/Aegisub
Fix crash when trying to open audio from file with no audio tracks
Originally committed to SVN as r5682.
This commit is contained in:
parent
7b1dea1a7a
commit
32463efb08
|
@ -122,7 +122,7 @@ AudioProvider *AudioProviderFactory::GetProvider(wxString filename, int cache) {
|
|||
}
|
||||
catch (AudioOpenError const& err) {
|
||||
found = true;
|
||||
msg += err.GetMessage();
|
||||
msg += err.GetMessage() + "\n";
|
||||
}
|
||||
}
|
||||
if (!provider) {
|
||||
|
@ -139,7 +139,7 @@ AudioProvider *AudioProviderFactory::GetProvider(wxString filename, int cache) {
|
|||
}
|
||||
catch (AudioOpenError const& err) {
|
||||
found = true;
|
||||
msg += list[i] + ": " + err.GetMessage();
|
||||
msg += list[i] + ": " + err.GetMessage() + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,14 +89,19 @@ struct audio_open : public Command {
|
|||
STR_HELP("Opens an audio file.")
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
wxString path = lagi_wxString(OPT_GET("Path/Last/Audio")->GetString());
|
||||
wxString str = wxString(_("Audio Formats")) + " (*.wav,*.mp3,*.ogg,*.flac,*.mp4,*.ac3,*.aac,*.mka,*.m4a,*.w64)|*.wav;*.mp3;*.ogg;*.flac;*.mp4;*.ac3;*.aac;*.mka;*.m4a;*.w64|"
|
||||
+ _("Video Formats") + " (*.avi,*.mkv,*.ogm,*.mpg,*.mpeg)|*.avi;*.mkv;*.ogm;*.mp4;*.mpeg;*.mpg|"
|
||||
+ _("All files") + " (*.*)|*.*";
|
||||
wxString filename = wxFileSelector(_("Open audio file"),path,"","",str,wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||
if (!filename.empty()) {
|
||||
c->audioController->OpenAudio(filename);
|
||||
OPT_SET("Path/Last/Audio")->SetString(STD_STR(filename));
|
||||
try {
|
||||
wxString path = lagi_wxString(OPT_GET("Path/Last/Audio")->GetString());
|
||||
wxString str = wxString(_("Audio Formats")) + " (*.wav,*.mp3,*.ogg,*.flac,*.mp4,*.ac3,*.aac,*.mka,*.m4a,*.w64)|*.wav;*.mp3;*.ogg;*.flac;*.mp4;*.ac3;*.aac;*.mka;*.m4a;*.w64|"
|
||||
+ _("Video Formats") + " (*.avi,*.mkv,*.ogm,*.mpg,*.mpeg)|*.avi;*.mkv;*.ogm;*.mp4;*.mpeg;*.mpg|"
|
||||
+ _("All files") + " (*.*)|*.*";
|
||||
wxString filename = wxFileSelector(_("Open audio file"),path,"","",str,wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||
if (!filename.empty()) {
|
||||
c->audioController->OpenAudio(filename);
|
||||
OPT_SET("Path/Last/Audio")->SetString(STD_STR(filename));
|
||||
}
|
||||
}
|
||||
catch (agi::Exception const& e) {
|
||||
wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxICON_ERROR | wxOK);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -141,7 +146,12 @@ struct audio_open_video : public Command {
|
|||
}
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
c->audioController->OpenAudio(c->videoController->videoName);
|
||||
try {
|
||||
c->audioController->OpenAudio(c->videoController->videoName);
|
||||
}
|
||||
catch (agi::Exception const& e) {
|
||||
wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxICON_ERROR | wxOK);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue