diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 30ac66ff1..528c1f3be 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -24,6 +24,8 @@ static constexpr char DISC_IMAGE_FILTER[] = MainWindow::MainWindow(QtHostInterface* host_interface) : QMainWindow(nullptr), m_host_interface(host_interface) { + m_host_interface->setMainWindow(this); + m_ui.setupUi(this); setupAdditionalUi(); connectSignals(); @@ -34,6 +36,7 @@ MainWindow::MainWindow(QtHostInterface* host_interface) : QMainWindow(nullptr), MainWindow::~MainWindow() { Assert(!m_display_widget); + m_host_interface->setMainWindow(nullptr); } void MainWindow::reportError(const QString& message) diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index 927d3f93c..90c0eae3e 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -10,6 +10,7 @@ #include "core/system.h" #include "frontend-common/sdl_audio_stream.h" #include "frontend-common/sdl_controller_interface.h" +#include "mainwindow.h" #include "opengldisplaywidget.h" #include "qtsettingsinterface.h" #include "qtutils.h" @@ -147,6 +148,12 @@ void QtHostInterface::refreshGameList(bool invalidate_cache /* = false */, bool emit gameListRefreshed(); } +void QtHostInterface::setMainWindow(MainWindow* window) +{ + DebugAssert((!m_main_window && window) || (m_main_window && !window)); + m_main_window = window; +} + QtDisplayWidget* QtHostInterface::createDisplayWidget() { Assert(!m_display_widget); diff --git a/src/duckstation-qt/qthostinterface.h b/src/duckstation-qt/qthostinterface.h index 2d9a8f8fd..17e1ca221 100644 --- a/src/duckstation-qt/qthostinterface.h +++ b/src/duckstation-qt/qthostinterface.h @@ -23,6 +23,7 @@ class QTimer; class GameList; +class MainWindow; class QtDisplayWidget; Q_DECLARE_METATYPE(SystemBootParameters); @@ -44,14 +45,16 @@ public: void putSettingValue(const QString& name, const QVariant& value); void removeSettingValue(const QString& name); - const GameList* getGameList() const { return m_game_list.get(); } - GameList* getGameList() { return m_game_list.get(); } + ALWAYS_INLINE const GameList* getGameList() const { return m_game_list.get(); } + ALWAYS_INLINE GameList* getGameList() { return m_game_list.get(); } void refreshGameList(bool invalidate_cache = false, bool invalidate_database = false); - const HotkeyInfoList& getHotkeyInfoList() const { return GetHotkeyInfoList(); } + ALWAYS_INLINE const HotkeyInfoList& getHotkeyInfoList() const { return GetHotkeyInfoList(); } - bool isOnWorkerThread() const { return QThread::currentThread() == m_worker_thread; } + ALWAYS_INLINE bool isOnWorkerThread() const { return QThread::currentThread() == m_worker_thread; } + ALWAYS_INLINE MainWindow* getMainWindow() const { return m_main_window; } + void setMainWindow(MainWindow* window); QtDisplayWidget* createDisplayWidget(); void populateSaveStateMenus(const char* game_code, QMenu* load_menu, QMenu* save_menu); @@ -156,6 +159,7 @@ private: QSettings m_qsettings; std::mutex m_qsettings_mutex; + MainWindow* m_main_window = nullptr; QtDisplayWidget* m_display_widget = nullptr; QThread* m_original_thread = nullptr; Thread* m_worker_thread = nullptr;