added try catch in nm (#2785)
* added try catch in nm * changelog * asdf * gh action
This commit is contained in:
@@ -149,31 +149,42 @@ void NativeMessagingServer::start()
|
||||
|
||||
void NativeMessagingServer::ReceiverThread::run()
|
||||
{
|
||||
ipc::message_queue::remove("chatterino_gui");
|
||||
ipc::message_queue messageQueue(ipc::open_or_create, "chatterino_gui", 100,
|
||||
MESSAGE_SIZE);
|
||||
|
||||
while (true)
|
||||
try
|
||||
{
|
||||
try
|
||||
ipc::message_queue::remove("chatterino_gui");
|
||||
ipc::message_queue messageQueue(ipc::open_or_create, "chatterino_gui",
|
||||
100, MESSAGE_SIZE);
|
||||
|
||||
while (true)
|
||||
{
|
||||
auto buf = std::make_unique<char[]>(MESSAGE_SIZE);
|
||||
auto retSize = ipc::message_queue::size_type();
|
||||
auto priority = static_cast<unsigned int>(0);
|
||||
try
|
||||
{
|
||||
auto buf = std::make_unique<char[]>(MESSAGE_SIZE);
|
||||
auto retSize = ipc::message_queue::size_type();
|
||||
auto priority = static_cast<unsigned int>(0);
|
||||
|
||||
messageQueue.receive(buf.get(), MESSAGE_SIZE, retSize, priority);
|
||||
messageQueue.receive(buf.get(), MESSAGE_SIZE, retSize,
|
||||
priority);
|
||||
|
||||
auto document = QJsonDocument::fromJson(
|
||||
QByteArray::fromRawData(buf.get(), retSize));
|
||||
auto document = QJsonDocument::fromJson(
|
||||
QByteArray::fromRawData(buf.get(), retSize));
|
||||
|
||||
this->handleMessage(document.object());
|
||||
}
|
||||
catch (ipc::interprocess_exception &ex)
|
||||
{
|
||||
qCDebug(chatterinoNativeMessage)
|
||||
<< "received from gui process:" << ex.what();
|
||||
this->handleMessage(document.object());
|
||||
}
|
||||
catch (ipc::interprocess_exception &ex)
|
||||
{
|
||||
qCDebug(chatterinoNativeMessage)
|
||||
<< "received from gui process:" << ex.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ipc::interprocess_exception &ex)
|
||||
{
|
||||
qCDebug(chatterinoNativeMessage)
|
||||
<< "run ipc message queue:" << ex.what();
|
||||
|
||||
nmIpcError().set(QString::fromLatin1(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
void NativeMessagingServer::ReceiverThread::handleMessage(
|
||||
@@ -272,4 +283,10 @@ void NativeMessagingServer::ReceiverThread::handleMessage(
|
||||
}
|
||||
}
|
||||
|
||||
Atomic<boost::optional<QString>> &nmIpcError()
|
||||
{
|
||||
static Atomic<boost::optional<QString>> x;
|
||||
return x;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user