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