From 2124c58daf0fe2248e977161490f218071a01c03 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Thu, 16 Aug 2007 23:17:54 +0000 Subject: [PATCH] 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. --- aegisub/audio_display.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/aegisub/audio_display.cpp b/aegisub/audio_display.cpp index 8f4c12e89..e920a7b75 100644 --- a/aegisub/audio_display.cpp +++ b/aegisub/audio_display.cpp @@ -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;