citra_qt: Better debug widget lifetime

This commit is contained in:
GPUCode 2023-12-28 00:33:20 +02:00
parent cf694f2350
commit 622ac9fca3
4 changed files with 27 additions and 4 deletions

View File

@ -19,7 +19,7 @@ int GPUCommandStreamItemModel::rowCount([[maybe_unused]] const QModelIndex& pare
} }
QVariant GPUCommandStreamItemModel::data(const QModelIndex& index, int role) const { QVariant GPUCommandStreamItemModel::data(const QModelIndex& index, int role) const {
if (!index.isValid()) if (!index.isValid() || !GetDebugger())
return QVariant(); return QVariant();
int command_index = index.row(); int command_index = index.row();
@ -74,16 +74,26 @@ GPUCommandStreamWidget::GPUCommandStreamWidget(Core::System& system_, QWidget* p
setWidget(command_list); setWidget(command_list);
} }
void GPUCommandStreamWidget::Register() {
auto& debugger = system.GPU().Debugger();
debugger.RegisterObserver(&model);
}
void GPUCommandStreamWidget::Unregister() {
auto& debugger = system.GPU().Debugger();
debugger.UnregisterObserver(&model);
}
void GPUCommandStreamWidget::showEvent(QShowEvent* event) { void GPUCommandStreamWidget::showEvent(QShowEvent* event) {
if (system.IsPoweredOn()) { if (system.IsPoweredOn()) {
system.GPU().Debugger().RegisterObserver(&model); Register();
} }
QDockWidget::showEvent(event); QDockWidget::showEvent(event);
} }
void GPUCommandStreamWidget::hideEvent(QHideEvent* event) { void GPUCommandStreamWidget::hideEvent(QHideEvent* event) {
if (system.IsPoweredOn()) { if (system.IsPoweredOn()) {
system.GPU().Debugger().UnregisterObserver(&model); Unregister();
} }
QDockWidget::hideEvent(event); QDockWidget::hideEvent(event);
} }

View File

@ -41,6 +41,9 @@ class GPUCommandStreamWidget : public QDockWidget {
public: public:
GPUCommandStreamWidget(Core::System& system, QWidget* parent = nullptr); GPUCommandStreamWidget(Core::System& system, QWidget* parent = nullptr);
void Register();
void Unregister();
protected: protected:
void showEvent(QShowEvent* event) override; void showEvent(QShowEvent* event) override;
void hideEvent(QHideEvent* event) override; void hideEvent(QHideEvent* event) override;

View File

@ -1237,6 +1237,11 @@ void GMainWindow::BootGame(const QString& filename) {
video_dumping_path.clear(); video_dumping_path.clear();
} }
// Register debug widgets
if (graphicsWidget->isVisible()) {
graphicsWidget->Register();
}
// Create and start the emulation thread // Create and start the emulation thread
emu_thread = std::make_unique<EmuThread>(system, *render_window); emu_thread = std::make_unique<EmuThread>(system, *render_window);
emit EmulationStarting(emu_thread.get()); emit EmulationStarting(emu_thread.get());
@ -1315,6 +1320,11 @@ void GMainWindow::ShutdownGame() {
// TODO(bunnei): This function is not thread safe, but it's being used as if it were // TODO(bunnei): This function is not thread safe, but it's being used as if it were
Pica::g_debug_context->ClearBreakpoints(); Pica::g_debug_context->ClearBreakpoints();
// Unregister debug widgets
if (graphicsWidget->isVisible()) {
graphicsWidget->Unregister();
}
// Frame advancing must be cancelled in order to release the emu thread from waiting // Frame advancing must be cancelled in order to release the emu thread from waiting
system.frame_limiter.SetFrameAdvancing(false); system.frame_limiter.SetFrameAdvancing(false);

View File

@ -346,7 +346,7 @@ std::shared_ptr<PageTable> MemorySystem::GetCurrentPageTable() const {
} }
void RasterizerFlushVirtualRegion(VAddr start, u32 size, FlushMode mode) { void RasterizerFlushVirtualRegion(VAddr start, u32 size, FlushMode mode) {
VAddr end = start + size; const VAddr end = start + size;
auto CheckRegion = [&](VAddr region_start, VAddr region_end, PAddr paddr_region_start) { auto CheckRegion = [&](VAddr region_start, VAddr region_end, PAddr paddr_region_start) {
if (start >= region_end || end <= region_start) { if (start >= region_end || end <= region_start) {