mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fixed memory corruption
This commit is contained in:
parent
1d097c3344
commit
47c93fb118
6 changed files with 17 additions and 18 deletions
|
@ -81,7 +81,7 @@ void Application::initialize(Settings &settings, Paths &paths)
|
||||||
|
|
||||||
this->windows->updateWordTypeMask();
|
this->windows->updateWordTypeMask();
|
||||||
|
|
||||||
this->initNm();
|
this->initNm(paths);
|
||||||
this->initPubsub();
|
this->initPubsub();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,17 +103,17 @@ void Application::save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::initNm()
|
void Application::initNm(Paths &paths)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
# ifdef QT_DEBUG
|
# ifdef QT_DEBUG
|
||||||
# ifdef C_DEBUG_NM
|
# ifdef C_DEBUG_NM
|
||||||
this->nativeMessaging->registerHost();
|
registerNmHost(paths);
|
||||||
this->nativeMessaging->openGuiMessageQueue();
|
this->nmServer.start();
|
||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
this->nativeMessaging->registerHost();
|
registerNmHost(paths);
|
||||||
this->nativeMessaging->openGuiMessageQueue();
|
this->nmServer.start();
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Singleton.hpp"
|
#include "common/Singleton.hpp"
|
||||||
|
#include "singletons/NativeMessaging.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -78,7 +79,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void addSingleton(Singleton *singleton);
|
void addSingleton(Singleton *singleton);
|
||||||
void initPubsub();
|
void initPubsub();
|
||||||
void initNm();
|
void initNm(Paths &paths);
|
||||||
|
|
||||||
template <typename T,
|
template <typename T,
|
||||||
typename = std::enable_if_t<std::is_base_of<Singleton, T>::value>>
|
typename = std::enable_if_t<std::is_base_of<Singleton, T>::value>>
|
||||||
|
@ -88,6 +89,8 @@ private:
|
||||||
this->singletons_.push_back(std::unique_ptr<T>(t));
|
this->singletons_.push_back(std::unique_ptr<T>(t));
|
||||||
return *t;
|
return *t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NativeMessagingServer nmServer{};
|
||||||
};
|
};
|
||||||
|
|
||||||
Application *getApp();
|
Application *getApp();
|
||||||
|
|
|
@ -217,7 +217,6 @@ void Emojis::loadEmojiSet()
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
getSettings()->emojiSet.connect([=](const auto &emojiSet, auto) {
|
getSettings()->emojiSet.connect([=](const auto &emojiSet, auto) {
|
||||||
log("Using emoji set {}", emojiSet);
|
|
||||||
this->emojis.each([=](const auto &name,
|
this->emojis.each([=](const auto &name,
|
||||||
std::shared_ptr<EmojiData> &emoji) {
|
std::shared_ptr<EmojiData> &emoji) {
|
||||||
QString emojiSetToUse = emojiSet;
|
QString emojiSetToUse = emojiSet;
|
||||||
|
|
|
@ -46,8 +46,6 @@ void TwitchBadges::loadTwitchBadges()
|
||||||
// "title"
|
// "title"
|
||||||
// "clickAction"
|
// "clickAction"
|
||||||
|
|
||||||
log("{} {}", key, vIt.key());
|
|
||||||
|
|
||||||
(*badgeSets)[key][vIt.key()] = std::make_shared<Emote>(emote);
|
(*badgeSets)[key][vIt.key()] = std::make_shared<Emote>(emote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,19 +141,18 @@ void NativeMessagingServer::start()
|
||||||
void NativeMessagingServer::ReceiverThread::run()
|
void NativeMessagingServer::ReceiverThread::run()
|
||||||
{
|
{
|
||||||
ipc::message_queue::remove("chatterino_gui");
|
ipc::message_queue::remove("chatterino_gui");
|
||||||
|
|
||||||
ipc::message_queue messageQueue(ipc::open_or_create, "chatterino_gui", 100,
|
ipc::message_queue messageQueue(ipc::open_or_create, "chatterino_gui", 100,
|
||||||
MESSAGE_SIZE);
|
MESSAGE_SIZE);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
std::unique_ptr<char> buf = std::make_unique<char>(MESSAGE_SIZE);
|
auto buf = std::make_unique<char[]>(MESSAGE_SIZE);
|
||||||
ipc::message_queue::size_type retSize;
|
auto retSize = ipc::message_queue::size_type();
|
||||||
unsigned int priority;
|
auto priority = static_cast<unsigned int>(0);
|
||||||
|
|
||||||
messageQueue.receive(buf.get(), MESSAGE_SIZE, retSize, priority);
|
messageQueue.receive(buf.get(), MESSAGE_SIZE, retSize, priority);
|
||||||
|
|
||||||
QJsonDocument 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());
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
class Application;
|
class Application;
|
||||||
class Paths;
|
class Paths;
|
||||||
|
|
||||||
namespace chatterino {
|
void registerNmHost(Paths &paths);
|
||||||
|
|
||||||
void registerNmHost(Application &app);
|
|
||||||
std::string &getNmQueueName(Paths &paths);
|
std::string &getNmQueueName(Paths &paths);
|
||||||
|
|
||||||
class NativeMessagingClient final
|
class NativeMessagingClient final
|
||||||
|
|
Loading…
Reference in a new issue