diff --git a/rpcs3/rpcs3qt/kernel_explorer.cpp b/rpcs3/rpcs3qt/kernel_explorer.cpp index 9ebe703aba..263d87e4c5 100644 --- a/rpcs3/rpcs3qt/kernel_explorer.cpp +++ b/rpcs3/rpcs3qt/kernel_explorer.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "Emu/IdManager.h" @@ -148,7 +149,9 @@ static QTreeWidgetItem* add_solid_node(QTreeWidget* tree, QTreeWidgetItem *paren return node; } -kernel_explorer::kernel_explorer(QWidget* parent) : QDialog(parent) +kernel_explorer::kernel_explorer(QWidget* parent, std::function on_destroy) + : QDialog(parent) + , m_on_destroy(on_destroy) { setWindowTitle(tr("Kernel Explorer")); setObjectName("kernel_explorer"); @@ -167,11 +170,10 @@ kernel_explorer::kernel_explorer(QWidget* parent) : QDialog(parent) m_tree->header()->close(); // Merge and display everything - vbox_panel->addSpacing(10); + vbox_panel->addSpacing(8); vbox_panel->addLayout(hbox_buttons); - vbox_panel->addSpacing(10); + vbox_panel->addSpacing(8); vbox_panel->addWidget(m_tree); - vbox_panel->addSpacing(10); setLayout(vbox_panel); // Events @@ -180,6 +182,11 @@ kernel_explorer::kernel_explorer(QWidget* parent) : QDialog(parent) Update(); } +kernel_explorer::~kernel_explorer() +{ + m_on_destroy(); +} + void kernel_explorer::Update() { const auto dct = g_fxo->get(); diff --git a/rpcs3/rpcs3qt/kernel_explorer.h b/rpcs3/rpcs3qt/kernel_explorer.h index 074227c6fe..bca13c165e 100644 --- a/rpcs3/rpcs3qt/kernel_explorer.h +++ b/rpcs3/rpcs3qt/kernel_explorer.h @@ -1,10 +1,11 @@ #pragma once #include -#include #include "util/types.hpp" +class QTreeWidget; + class kernel_explorer : public QDialog { Q_OBJECT @@ -25,10 +26,12 @@ class kernel_explorer : public QDialog }; public: - kernel_explorer(QWidget* parent); + kernel_explorer(QWidget* parent, std::function on_destroy); + ~kernel_explorer(); private: QTreeWidget* m_tree; + std::function m_on_destroy; private Q_SLOTS: void Update(); diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index d347488892..bdbf58a865 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -1238,6 +1238,12 @@ void main_window::OnEmuStop() { m_game_list_frame->Refresh(); } + + // Close kernel explorer if running + if (m_kernel_explorer) + { + m_kernel_explorer->close(); + } } void main_window::OnEmuReady() @@ -1759,8 +1765,15 @@ void main_window::CreateConnects() connect(ui->toolskernel_explorerAct, &QAction::triggered, [this] { - kernel_explorer* kernelExplorer = new kernel_explorer(this); - kernelExplorer->show(); + if (!m_kernel_explorer) + { + m_kernel_explorer = new kernel_explorer(this, [this]() + { + m_kernel_explorer = nullptr; + }); + } + + m_kernel_explorer->show(); }); connect(ui->toolsmemory_viewerAct, &QAction::triggered, [this] diff --git a/rpcs3/rpcs3qt/main_window.h b/rpcs3/rpcs3qt/main_window.h index 8eb84d50e9..e5638e1ecb 100644 --- a/rpcs3/rpcs3qt/main_window.h +++ b/rpcs3/rpcs3qt/main_window.h @@ -21,6 +21,7 @@ class game_list_frame; class gui_settings; class emu_settings; class persistent_settings; +class kernel_explorer; struct gui_game_info; @@ -164,6 +165,7 @@ private: log_frame* m_log_frame = nullptr; debugger_frame* m_debugger_frame = nullptr; game_list_frame* m_game_list_frame = nullptr; + kernel_explorer* m_kernel_explorer = nullptr; std::shared_ptr m_gui_settings; std::shared_ptr m_emu_settings; std::shared_ptr m_persistent_settings;