Add a little more error reporting to audio loading, also catch unspecified exceptions now. Additionally make sure to null out some pointers that might be delete'd during exception handling. (Also, GET.)

Originally committed to SVN as r1500.
This commit is contained in:
Niels Martin Hansen 2007-08-16 23:17:54 +00:00
parent 720ee8c309
commit 2124c58daf

View file

@ -808,7 +808,7 @@ void AudioDisplay::SetScale(float _scale) {
void AudioDisplay::SetFile(wxString file) {
wxLogDebug(_T("AudioDisplay::SetFile(file=%s)"), file.c_str());
// Unload
if (file.IsEmpty()) {
if (file.IsEmpty()) try {
wxLogDebug(_T("AudioDisplay::SetFile: file is empty, just closing audio"));
try {
if (player) player->CloseStream();
@ -833,6 +833,15 @@ void AudioDisplay::SetFile(wxString file) {
temporary = false;
StandardPaths::SetPathValue(_T("?audio"),_T(""));
}
catch (wxString e) {
wxLogError(e);
}
catch (const wxChar *e) {
wxLogError(e);
}
catch (...) {
wxLogError(_T("Unknown error unloading audio"));
}
// Load
else {
@ -876,16 +885,21 @@ void AudioDisplay::SetFile(wxString file) {
UpdateImage();
}
catch (const wxChar *e) {
if (player) delete player;
if (provider) delete provider;
if (player) { delete player; player = 0; }
if (provider) { delete provider; provider = 0; }
wxLogError(e);
}
catch (wxString &err) {
if (player) delete player;
if (provider) delete provider;
if (player) { delete player; player = 0; }
if (provider) { delete provider; provider = 0; }
wxLogDebug(_T("AudioDisplay::SetFile: gotcha!"));
wxMessageBox(err,_T("Error loading audio"),wxICON_ERROR | wxOK);
}
catch (...) {
if (player) { delete player; player = 0; }
if (provider) { delete provider; provider = 0; }
wxLogError(_T("Unknown error loading audio"));
}
}
if (!loaded) return;