qt: Only register graphics debugger as observer if visible. (#6875)

This commit is contained in:
Steveice10 2023-08-09 17:31:09 -07:00 committed by GitHub
parent 33a2113b71
commit baca2bfc6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View file

@ -64,15 +64,22 @@ void GPUCommandStreamItemModel::OnGXCommandFinishedInternal(int total_command_co
} }
GPUCommandStreamWidget::GPUCommandStreamWidget(QWidget* parent) GPUCommandStreamWidget::GPUCommandStreamWidget(QWidget* parent)
: QDockWidget(tr("Graphics Debugger"), parent) { : QDockWidget(tr("Graphics Debugger"), parent), model(this) {
setObjectName(QStringLiteral("GraphicsDebugger")); setObjectName(QStringLiteral("GraphicsDebugger"));
GPUCommandStreamItemModel* command_model = new GPUCommandStreamItemModel(this); auto* command_list = new QListView;
g_debugger.RegisterObserver(command_model); command_list->setModel(&model);
QListView* command_list = new QListView;
command_list->setModel(command_model);
command_list->setFont(GetMonospaceFont()); command_list->setFont(GetMonospaceFont());
setWidget(command_list); 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);
}

View file

@ -37,5 +37,10 @@ class GPUCommandStreamWidget : public QDockWidget {
public: public:
GPUCommandStreamWidget(QWidget* parent = nullptr); GPUCommandStreamWidget(QWidget* parent = nullptr);
protected:
void showEvent(QShowEvent* event) override;
void hideEvent(QHideEvent* event) override;
private: private:
GPUCommandStreamItemModel model;
}; };