| 1196 | #endif //_MSC_VER |
| 1197 | |
| 1198 | bool AudacityApp::OnExceptionInMainLoop() |
| 1199 | { |
| 1200 | // This function is invoked from catch blocks in the wxWidgets framework, |
| 1201 | // and throw; without argument re-throws the exception being handled, |
| 1202 | // letting us dispatch according to its type. |
| 1203 | |
| 1204 | try { throw; } |
| 1205 | catch ( AudacityException &e ) { |
| 1206 | (void)e;// Compiler food |
| 1207 | // Here is the catch-all for our own exceptions |
| 1208 | |
| 1209 | // Use CallAfter to delay this to the next pass of the event loop, |
| 1210 | // rather than risk doing it inside stack unwinding. |
| 1211 | auto pProject = ::GetActiveProject().lock(); |
| 1212 | auto pException = std::current_exception(); |
| 1213 | CallAfter( [pException, pProject] { |
| 1214 | |
| 1215 | // Restore the state of the project to what it was before the |
| 1216 | // failed operation |
| 1217 | if (pProject) { |
| 1218 | ProjectHistory::Get( *pProject ).RollbackState(); |
| 1219 | |
| 1220 | // Forget pending changes in the TrackList |
| 1221 | PendingTracks::Get(*pProject).ClearPendingTracks(); |
| 1222 | Viewport::Get(*pProject).Redraw(); |
| 1223 | } |
| 1224 | |
| 1225 | // Give the user an alert |
| 1226 | try { std::rethrow_exception( pException ); } |
| 1227 | catch( AudacityException &e ) |
| 1228 | { e.DelayedHandlerAction(); } |
| 1229 | |
| 1230 | } ); |
| 1231 | |
| 1232 | // Don't quit the program |
| 1233 | return true; |
| 1234 | } |
| 1235 | catch ( ... ) { |
| 1236 | // There was some other type of exception we don't know. |
| 1237 | // Let the inherited function do throw; again and whatever else it does. |
| 1238 | return wxApp::OnExceptionInMainLoop(); |
| 1239 | } |
| 1240 | // Shouldn't ever reach this line |
| 1241 | return false; |
| 1242 | } |
| 1243 | #ifdef _MSC_VER |
| 1244 | #pragma warning( pop ) |
| 1245 | #endif //_MSC_VER |
no test coverage detected