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->initNm();
|
||||
this->initNm(paths);
|
||||
this->initPubsub();
|
||||
}
|
||||
|
||||
|
@ -103,17 +103,17 @@ void Application::save()
|
|||
}
|
||||
}
|
||||
|
||||
void Application::initNm()
|
||||
void Application::initNm(Paths &paths)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
# ifdef QT_DEBUG
|
||||
# ifdef C_DEBUG_NM
|
||||
this->nativeMessaging->registerHost();
|
||||
this->nativeMessaging->openGuiMessageQueue();
|
||||
registerNmHost(paths);
|
||||
this->nmServer.start();
|
||||
# endif
|
||||
# else
|
||||
this->nativeMessaging->registerHost();
|
||||
this->nativeMessaging->openGuiMessageQueue();
|
||||
registerNmHost(paths);
|
||||
this->nmServer.start();
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "common/Singleton.hpp"
|
||||
#include "singletons/NativeMessaging.hpp"
|
||||
|
||||
#include <QApplication>
|
||||
#include <memory>
|
||||
|
@ -78,7 +79,7 @@ public:
|
|||
private:
|
||||
void addSingleton(Singleton *singleton);
|
||||
void initPubsub();
|
||||
void initNm();
|
||||
void initNm(Paths &paths);
|
||||
|
||||
template <typename T,
|
||||
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));
|
||||
return *t;
|
||||
}
|
||||
|
||||
NativeMessagingServer nmServer{};
|
||||
};
|
||||
|
||||
Application *getApp();
|
||||
|
|
|
@ -217,7 +217,6 @@ void Emojis::loadEmojiSet()
|
|||
auto app = getApp();
|
||||
|
||||
getSettings()->emojiSet.connect([=](const auto &emojiSet, auto) {
|
||||
log("Using emoji set {}", emojiSet);
|
||||
this->emojis.each([=](const auto &name,
|
||||
std::shared_ptr<EmojiData> &emoji) {
|
||||
QString emojiSetToUse = emojiSet;
|
||||
|
|
|
@ -46,8 +46,6 @@ void TwitchBadges::loadTwitchBadges()
|
|||
// "title"
|
||||
// "clickAction"
|
||||
|
||||
log("{} {}", key, vIt.key());
|
||||
|
||||
(*badgeSets)[key][vIt.key()] = std::make_shared<Emote>(emote);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,19 +141,18 @@ 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 {
|
||||
std::unique_ptr<char> buf = std::make_unique<char>(MESSAGE_SIZE);
|
||||
ipc::message_queue::size_type retSize;
|
||||
unsigned int priority;
|
||||
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);
|
||||
|
||||
QJsonDocument document = QJsonDocument::fromJson(
|
||||
auto document = QJsonDocument::fromJson(
|
||||
QByteArray::fromRawData(buf.get(), retSize));
|
||||
|
||||
this->handleMessage(document.object());
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
#include <QThread>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class Application;
|
||||
class Paths;
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
void registerNmHost(Application &app);
|
||||
void registerNmHost(Paths &paths);
|
||||
std::string &getNmQueueName(Paths &paths);
|
||||
|
||||
class NativeMessagingClient final
|
||||
|
|
Loading…
Reference in a new issue