mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-09-03 16:16:05 +00:00
Merge pull request #13620 from JosJuice/logmanager-cleanup
LogManager: Stop using manual memory management
This commit is contained in:
commit
63572f15fc
4 changed files with 39 additions and 24 deletions
|
@ -52,15 +52,16 @@ LogWidget::LogWidget(QWidget* parent) : QDockWidget(parent), m_timer(new QTimer(
|
|||
|
||||
connect(&Settings::Instance(), &Settings::DebugFontChanged, this, &LogWidget::UpdateFont);
|
||||
|
||||
Common::Log::LogManager::GetInstance()->RegisterListener(LogListener::LOG_WINDOW_LISTENER, this);
|
||||
Common::Log::LogManager::GetInstance()->RegisterListener(
|
||||
Common::Log::LogListener::LOG_WINDOW_LISTENER, std::make_unique<LogListenerImpl>(this));
|
||||
}
|
||||
|
||||
LogWidget::~LogWidget()
|
||||
{
|
||||
SaveSettings();
|
||||
|
||||
Common::Log::LogManager::GetInstance()->RegisterListener(LogListener::LOG_WINDOW_LISTENER,
|
||||
nullptr);
|
||||
Common::Log::LogManager::GetInstance()->RegisterListener(
|
||||
Common::Log::LogListener::LOG_WINDOW_LISTENER, nullptr);
|
||||
}
|
||||
|
||||
void LogWidget::UpdateLog()
|
||||
|
|
|
@ -18,7 +18,7 @@ class QPlainTextEdit;
|
|||
class QPushButton;
|
||||
class QTimer;
|
||||
|
||||
class LogWidget final : public QDockWidget, Common::Log::LogListener
|
||||
class LogWidget final : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -29,6 +29,23 @@ protected:
|
|||
void closeEvent(QCloseEvent*) override;
|
||||
|
||||
private:
|
||||
// LogListener instances are owned by LogManager, so we can't make LogWidget inherit from
|
||||
// LogListener, since Qt should be in control of LogWidget's lifetime. Instead we have
|
||||
// this LogListenerImpl class to act as an adapter.
|
||||
class LogListenerImpl final : public Common::Log::LogListener
|
||||
{
|
||||
public:
|
||||
explicit LogListenerImpl(LogWidget* log_widget) : m_log_widget(log_widget) {}
|
||||
|
||||
private:
|
||||
void Log(Common::Log::LogLevel level, const char* text) override
|
||||
{
|
||||
m_log_widget->Log(level, text);
|
||||
}
|
||||
|
||||
LogWidget* m_log_widget;
|
||||
};
|
||||
|
||||
void UpdateLog();
|
||||
void UpdateFont();
|
||||
void CreateWidgets();
|
||||
|
@ -36,7 +53,7 @@ private:
|
|||
void LoadSettings();
|
||||
void SaveSettings();
|
||||
|
||||
void Log(Common::Log::LogLevel level, const char* text) override;
|
||||
void Log(Common::Log::LogLevel level, const char* text);
|
||||
|
||||
// Log
|
||||
QCheckBox* m_log_wrap;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue