mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
a6f4cb1647
Currently, it is possible for the DiscordHandler thread to be in the middle of sleeping when Dolphin is closing. This results in a very noticeable delay of up to 2 seconds that is unacceptable, especially for people who don't use the Discord integration. This fixes the issue by making the thread wait on an Event instead and signalling it when shutting down.
52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
// Copyright 2018 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <list>
|
|
#include <mutex>
|
|
#include <thread>
|
|
|
|
#include <QObject>
|
|
|
|
#include "Common/Event.h"
|
|
#include "Common/Flag.h"
|
|
|
|
#include "UICommon/DiscordPresence.h"
|
|
|
|
class DiscordJoinRequestDialog;
|
|
|
|
class DiscordHandler : public QObject, public Discord::Handler
|
|
{
|
|
Q_OBJECT
|
|
#ifdef USE_DISCORD_PRESENCE
|
|
public:
|
|
explicit DiscordHandler(QWidget* parent);
|
|
~DiscordHandler();
|
|
|
|
void Start();
|
|
void Stop();
|
|
void DiscordJoin() override;
|
|
void DiscordJoinRequest(const char* id, const std::string& discord_tag,
|
|
const char* avatar) override;
|
|
void ShowNewJoinRequest(const std::string& id, const std::string& discord_tag,
|
|
const std::string& avatar);
|
|
#endif
|
|
|
|
signals:
|
|
void Join();
|
|
void JoinRequest(const std::string id, const std::string discord_tag, const std::string avatar);
|
|
|
|
#ifdef USE_DISCORD_PRESENCE
|
|
private:
|
|
void Run();
|
|
QWidget* m_parent;
|
|
Common::Flag m_stop_requested;
|
|
Common::Event m_wakeup_event;
|
|
std::thread m_thread;
|
|
std::list<DiscordJoinRequestDialog> m_request_dialogs;
|
|
std::mutex m_request_dialogs_mutex;
|
|
#endif
|
|
};
|