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) {
|
catch (AudioOpenError const& err) {
|
||||||
found = true;
|
found = true;
|
||||||
msg += err.GetMessage();
|
msg += err.GetMessage() + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
|
@ -139,7 +139,7 @@ AudioProvider *AudioProviderFactory::GetProvider(wxString filename, int cache) {
|
||||||
}
|
}
|
||||||
catch (AudioOpenError const& err) {
|
catch (AudioOpenError const& err) {
|
||||||
found = true;
|
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.")
|
STR_HELP("Opens an audio file.")
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
wxString path = lagi_wxString(OPT_GET("Path/Last/Audio")->GetString());
|
try {
|
||||||
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|"
|
wxString path = lagi_wxString(OPT_GET("Path/Last/Audio")->GetString());
|
||||||
+ _("Video Formats") + " (*.avi,*.mkv,*.ogm,*.mpg,*.mpeg)|*.avi;*.mkv;*.ogm;*.mp4;*.mpeg;*.mpg|"
|
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|"
|
||||||
+ _("All files") + " (*.*)|*.*";
|
+ _("Video Formats") + " (*.avi,*.mkv,*.ogm,*.mpg,*.mpeg)|*.avi;*.mkv;*.ogm;*.mp4;*.mpeg;*.mpg|"
|
||||||
wxString filename = wxFileSelector(_("Open audio file"),path,"","",str,wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
+ _("All files") + " (*.*)|*.*";
|
||||||
if (!filename.empty()) {
|
wxString filename = wxFileSelector(_("Open audio file"),path,"","",str,wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||||
c->audioController->OpenAudio(filename);
|
if (!filename.empty()) {
|
||||||
OPT_SET("Path/Last/Audio")->SetString(STD_STR(filename));
|
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) {
|
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