mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added try catch in nm (#2785)
* added try catch in nm * changelog * asdf * gh action
This commit is contained in:
parent
6732b25f36
commit
6ae8427fc6
|
@ -7,6 +7,7 @@
|
|||
- Minor: Hosting messages are now clickable. (#2655)
|
||||
- Minor: Messages held by automod are now shown to the user. (#2626)
|
||||
- Minor: Load 100 blocked users rather than the default 20. (#2772)
|
||||
- Bugfix: Fixed a potential crashing issue related to the browser extension. (#2774)
|
||||
- Bugfix: Strip newlines from stream titles to prevent text going off of split header (#2755)
|
||||
- Bugfix: Automod messages now work properly again. (#2682)
|
||||
- Bugfix: `Login expired` message no longer highlights all tabs. (#2735)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QThread>
|
||||
#include <boost/optional.hpp>
|
||||
#include <common/Atomic.hpp>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
@ -10,6 +13,8 @@ class Paths;
|
|||
void registerNmHost(Paths &paths);
|
||||
std::string &getNmQueueName(Paths &paths);
|
||||
|
||||
Atomic<boost::optional<QString>> &nmIpcError();
|
||||
|
||||
class NativeMessagingClient final
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "Application.hpp"
|
||||
#include "common/Version.hpp"
|
||||
#include "singletons/Fonts.hpp"
|
||||
#include "singletons/NativeMessaging.hpp"
|
||||
#include "singletons/Paths.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "singletons/WindowManager.hpp"
|
||||
|
@ -442,6 +443,16 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
|||
layout.addDescription("The browser extension replaces the default "
|
||||
"Twitch.tv chat with chatterino.");
|
||||
|
||||
{
|
||||
if (auto err = nmIpcError().get())
|
||||
{
|
||||
layout.addDescription(
|
||||
"An error happened during initialization of the "
|
||||
"browser extension: " +
|
||||
*err);
|
||||
}
|
||||
}
|
||||
|
||||
layout.addDescription(formatRichNamedLink(
|
||||
CHROME_EXTENSION_LINK,
|
||||
"Download for Google Chrome and similar browsers."));
|
||||
|
|
Loading…
Reference in a new issue