From baca2bfc6bd0af97ce74b911d69af2391815c9d7 Mon Sep 17 00:00:00 2001 From: Steveice10 <1269164+Steveice10@users.noreply.github.com> Date: Wed, 9 Aug 2023 17:31:09 -0700 Subject: [PATCH] qt: Only register graphics debugger as observer if visible. (#6875) --- src/citra_qt/debugger/graphics/graphics.cpp | 19 +++++++++++++------ src/citra_qt/debugger/graphics/graphics.h | 5 +++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/citra_qt/debugger/graphics/graphics.cpp b/src/citra_qt/debugger/graphics/graphics.cpp index 1a3c0157c..674b83100 100644 --- a/src/citra_qt/debugger/graphics/graphics.cpp +++ b/src/citra_qt/debugger/graphics/graphics.cpp @@ -64,15 +64,22 @@ void GPUCommandStreamItemModel::OnGXCommandFinishedInternal(int total_command_co } GPUCommandStreamWidget::GPUCommandStreamWidget(QWidget* parent) - : QDockWidget(tr("Graphics Debugger"), parent) { + : QDockWidget(tr("Graphics Debugger"), parent), model(this) { setObjectName(QStringLiteral("GraphicsDebugger")); - GPUCommandStreamItemModel* command_model = new GPUCommandStreamItemModel(this); - g_debugger.RegisterObserver(command_model); - - QListView* command_list = new QListView; - command_list->setModel(command_model); + auto* command_list = new QListView; + command_list->setModel(&model); command_list->setFont(GetMonospaceFont()); setWidget(command_list); } + +void GPUCommandStreamWidget::showEvent(QShowEvent* event) { + g_debugger.RegisterObserver(&model); + QDockWidget::showEvent(event); +} + +void GPUCommandStreamWidget::hideEvent(QHideEvent* event) { + g_debugger.UnregisterObserver(&model); + QDockWidget::hideEvent(event); +} diff --git a/src/citra_qt/debugger/graphics/graphics.h b/src/citra_qt/debugger/graphics/graphics.h index 8837fb792..9193c2821 100644 --- a/src/citra_qt/debugger/graphics/graphics.h +++ b/src/citra_qt/debugger/graphics/graphics.h @@ -37,5 +37,10 @@ class GPUCommandStreamWidget : public QDockWidget { public: GPUCommandStreamWidget(QWidget* parent = nullptr); +protected: + void showEvent(QShowEvent* event) override; + void hideEvent(QHideEvent* event) override; + private: + GPUCommandStreamItemModel model; };