Skip to content

Commit

Permalink
Debugger: Fix an issue where the debugger is always on top of the mai…
Browse files Browse the repository at this point in the history
…n window

Add an optional "always on top" toolbar button as well
  • Loading branch information
F0bes committed Oct 12, 2023
1 parent 312a583 commit 48788c4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pcsx2-qt/Debugger/DebuggerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ DebuggerWindow::DebuggerWindow(QWidget* parent)
connect(m_ui.actionStepInto, &QAction::triggered, this, &DebuggerWindow::onStepInto);
connect(m_ui.actionStepOver, &QAction::triggered, this, &DebuggerWindow::onStepOver);
connect(m_ui.actionStepOut, &QAction::triggered, this, &DebuggerWindow::onStepOut);
connect(m_ui.actionOnTop, &QAction::triggered, [this] { this->setWindowFlags(this->windowFlags() ^ Qt::WindowStaysOnTopHint); this->show(); });

connect(g_emu_thread, &EmuThread::onVMPaused, this, &DebuggerWindow::onVMStateChanged);
connect(g_emu_thread, &EmuThread::onVMResumed, this, &DebuggerWindow::onVMStateChanged);

onVMStateChanged(); // If we missed a state change while we weren't loaded

// We can't do this in the designer, but we want to right align the actionOnTop action in the toolbar
QWidget* spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_ui.toolBar->insertWidget(m_ui.actionOnTop, spacer);

m_cpuWidget_r5900 = new CpuWidget(this, r5900Debug);
m_cpuWidget_r3000 = new CpuWidget(this, r3000Debug);
Expand Down
12 changes: 12 additions & 0 deletions pcsx2-qt/Debugger/DebuggerWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<addaction name="actionStepInto"/>
<addaction name="actionStepOver"/>
<addaction name="actionStepOut"/>
<addaction name="actionOnTop"/>
</widget>
<action name="actionRun">
<property name="icon">
Expand Down Expand Up @@ -88,6 +89,17 @@
<string>Shift+F11</string>
</property>
</action>
<action name="actionOnTop">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Always On Top</string>
</property>
<property name="toolTip">
<string>Show this window on top</string>
</property>
</action>
</widget>
<resources/>
<connections/>
Expand Down
10 changes: 9 additions & 1 deletion pcsx2-qt/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,13 @@ void MainWindow::requestExit(bool allow_confirm)
if (!requestShutdown(allow_confirm, true, EmuConfig.SaveStateOnShutdown))
return;

if (m_debugger_window)
{
m_debugger_window->close();
m_debugger_window->deleteLater();
m_debugger_window = nullptr;
}

// VM stopped signal won't have fired yet, so queue an exit if we still have one.
// Otherwise, immediately exit, because there's no VM to exit us later.
if (vm_was_valid)
Expand Down Expand Up @@ -2300,7 +2307,8 @@ void MainWindow::doSettings(const char* category /* = nullptr */)
DebuggerWindow* MainWindow::getDebuggerWindow()
{
if (!m_debugger_window)
m_debugger_window = new DebuggerWindow(this);
// Don't pass us (this) as the parent, otherwise the window is always on top of the mainwindow (on windows at least)
m_debugger_window = new DebuggerWindow(nullptr);

return m_debugger_window;
}
Expand Down

0 comments on commit 48788c4

Please sign in to comment.