added try catch in nm (#2785)
* added try catch in nm * changelog * asdf * gh action
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
- Minor: Hosting messages are now clickable. (#2655)
|
- Minor: Hosting messages are now clickable. (#2655)
|
||||||
- Minor: Messages held by automod are now shown to the user. (#2626)
|
- Minor: Messages held by automod are now shown to the user. (#2626)
|
||||||
- Minor: Load 100 blocked users rather than the default 20. (#2772)
|
- 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: Strip newlines from stream titles to prevent text going off of split header (#2755)
|
||||||
- Bugfix: Automod messages now work properly again. (#2682)
|
- Bugfix: Automod messages now work properly again. (#2682)
|
||||||
- Bugfix: `Login expired` message no longer highlights all tabs. (#2735)
|
- Bugfix: `Login expired` message no longer highlights all tabs. (#2735)
|
||||||
|
|||||||
@@ -149,31 +149,42 @@ void NativeMessagingServer::start()
|
|||||||
|
|
||||||
void NativeMessagingServer::ReceiverThread::run()
|
void NativeMessagingServer::ReceiverThread::run()
|
||||||
{
|
{
|
||||||
ipc::message_queue::remove("chatterino_gui");
|
try
|
||||||
ipc::message_queue messageQueue(ipc::open_or_create, "chatterino_gui", 100,
|
|
||||||
MESSAGE_SIZE);
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
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);
|
try
|
||||||
auto retSize = ipc::message_queue::size_type();
|
{
|
||||||
auto priority = static_cast<unsigned int>(0);
|
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(
|
auto document = QJsonDocument::fromJson(
|
||||||
QByteArray::fromRawData(buf.get(), retSize));
|
QByteArray::fromRawData(buf.get(), retSize));
|
||||||
|
|
||||||
this->handleMessage(document.object());
|
this->handleMessage(document.object());
|
||||||
}
|
}
|
||||||
catch (ipc::interprocess_exception &ex)
|
catch (ipc::interprocess_exception &ex)
|
||||||
{
|
{
|
||||||
qCDebug(chatterinoNativeMessage)
|
qCDebug(chatterinoNativeMessage)
|
||||||
<< "received from gui process:" << ex.what();
|
<< "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(
|
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
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <boost/optional.hpp>
|
||||||
|
#include <common/Atomic.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
@@ -10,6 +13,8 @@ class Paths;
|
|||||||
void registerNmHost(Paths &paths);
|
void registerNmHost(Paths &paths);
|
||||||
std::string &getNmQueueName(Paths &paths);
|
std::string &getNmQueueName(Paths &paths);
|
||||||
|
|
||||||
|
Atomic<boost::optional<QString>> &nmIpcError();
|
||||||
|
|
||||||
class NativeMessagingClient final
|
class NativeMessagingClient final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "common/Version.hpp"
|
#include "common/Version.hpp"
|
||||||
#include "singletons/Fonts.hpp"
|
#include "singletons/Fonts.hpp"
|
||||||
|
#include "singletons/NativeMessaging.hpp"
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
#include "singletons/WindowManager.hpp"
|
#include "singletons/WindowManager.hpp"
|
||||||
@@ -442,6 +443,16 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
|||||||
layout.addDescription("The browser extension replaces the default "
|
layout.addDescription("The browser extension replaces the default "
|
||||||
"Twitch.tv chat with chatterino.");
|
"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(
|
layout.addDescription(formatRichNamedLink(
|
||||||
CHROME_EXTENSION_LINK,
|
CHROME_EXTENSION_LINK,
|
||||||
"Download for Google Chrome and similar browsers."));
|
"Download for Google Chrome and similar browsers."));
|
||||||
|
|||||||
Reference in New Issue
Block a user