fix: terminator handler does not work as expected

fix #887
This commit is contained in:
YiFang Xiao 2023-07-08 21:57:21 +08:00
parent f52e998524
commit e85609ce42
2 changed files with 2 additions and 21 deletions

View file

@ -19,7 +19,7 @@ SpeechClient::Engines SpeechClient::availableEngines()
const auto sp = new QTextToSpeech( engine_name );
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
if ( !sp || sp->state() == QTextToSpeech::Error )
if ( sp->state() == QTextToSpeech::Error )
continue;
#else
if ( !sp || sp->state() == QTextToSpeech::BackendError )

View file

@ -9,26 +9,7 @@
static void termHandler()
{
// Trick: In c++17, there is no standardized way to know the exception name/type inside terminate_handler
// So, we just get the exception and throw it again, so that we can call the std::exception::what :)
// This trick can be removed/improved if something similar to
// boost::current_exception_diagnostic_information got standardized,
std::exception_ptr curException = std::current_exception();
try {
if ( curException != nullptr ) {
std::rethrow_exception( curException );
}
else {
qDebug() << "GoldenDict has crashed unexpectedly.\n\n";
}
}
catch ( const std::exception & e ) {
qDebug() << "GoldenDict has crashed with exception: " << e.what() ;
}
qDebug() << "GoldenDict has crashed unexpectedly.\n\n";
if( logFilePtr && logFilePtr->isOpen() )
logFilePtr->close();