Do not let exceptions cross Qt signal dispatcher

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5252 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2015-04-20 17:47:32 +00:00
parent 0992dc9a5e
commit 129c3ccde0
2 changed files with 155 additions and 129 deletions

View File

@ -1,5 +1,7 @@
#include "MessageClient.hpp" #include "MessageClient.hpp"
#include <stdexcept>
#include <QUdpSocket> #include <QUdpSocket>
#include <QHostInfo> #include <QHostInfo>
#include <QTimer> #include <QTimer>
@ -81,6 +83,8 @@ void MessageClient::impl::pending_datagrams ()
} }
void MessageClient::impl::parse_message (QByteArray const& msg) void MessageClient::impl::parse_message (QByteArray const& msg)
{
try
{ {
// //
// message format is described in NetworkMessage.hpp // message format is described in NetworkMessage.hpp
@ -125,6 +129,15 @@ void MessageClient::impl::parse_message (QByteArray const& msg)
} }
} }
} }
catch (std::exception const& e)
{
Q_EMIT self_->error (QString {"MessageClient exception: %1"}.arg (e.what ()));
}
catch (...)
{
Q_EMIT self_->error ("Unexpected exception in MessageClient");
}
}
void MessageClient::impl::heartbeat () void MessageClient::impl::heartbeat ()
{ {

View File

@ -1,5 +1,7 @@
#include "MessageServer.hpp" #include "MessageServer.hpp"
#include <stdexcept>
#include <QUdpSocket> #include <QUdpSocket>
#include <QTimer> #include <QTimer>
#include <QHash> #include <QHash>
@ -99,6 +101,8 @@ void MessageServer::impl::pending_datagrams ()
} }
void MessageServer::impl::parse_message (QHostAddress const& sender, port_type sender_port, QByteArray const& msg) void MessageServer::impl::parse_message (QHostAddress const& sender, port_type sender_port, QByteArray const& msg)
{
try
{ {
// //
// message format is described in NetworkMessage.hpp // message format is described in NetworkMessage.hpp
@ -203,6 +207,15 @@ void MessageServer::impl::parse_message (QHostAddress const& sender, port_type s
break; break;
} }
} }
catch (std::exception const& e)
{
Q_EMIT self_->error (QString {"MessageServer exception: %1"}.arg (e.what ()));
}
catch (...)
{
Q_EMIT self_->error ("Unexpected exception in MessageServer");
}
}
void MessageServer::impl::tick () void MessageServer::impl::tick ()
{ {