Add some better error catching+reporting in audio loading/unloading. (Don't just crash.)

Originally committed to SVN as r1499.
This commit is contained in:
Niels Martin Hansen 2007-08-16 22:45:29 +00:00
parent 6bb162523b
commit 720ee8c309
1 changed files with 17 additions and 2 deletions

View File

@ -810,14 +810,24 @@ void AudioDisplay::SetFile(wxString file) {
// Unload
if (file.IsEmpty()) {
wxLogDebug(_T("AudioDisplay::SetFile: file is empty, just closing audio"));
if (player) player->CloseStream();
try {
if (player) player->CloseStream();
}
catch (const wxChar *e) {
wxLogError(e);
}
delete provider;
delete player;
delete spectrumRenderer;
provider = NULL;
player = NULL;
spectrumRenderer = NULL;
Reset();
try {
Reset();
}
catch (const wxChar *e) {
wxLogError(e);
}
loaded = false;
temporary = false;
@ -865,6 +875,11 @@ void AudioDisplay::SetFile(wxString file) {
// Update
UpdateImage();
}
catch (const wxChar *e) {
if (player) delete player;
if (provider) delete provider;
wxLogError(e);
}
catch (wxString &err) {
if (player) delete player;
if (provider) delete provider;