From 78c138d35f2b4a1b13862d035a434286c05ac414 Mon Sep 17 00:00:00 2001 From: weakboson Date: Thu, 24 Jul 2025 14:00:43 +0800 Subject: [PATCH] [frontend] Detect windowHandle properly when `GRenderWindow` is not native. --- src/yuzu/bootmanager.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index d14c46af86..67920fb552 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -284,8 +284,8 @@ struct NullRenderWidget : public RenderWidget { GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_, std::shared_ptr input_subsystem_, Core::System& system_) - : QWidget(parent), - emu_thread(emu_thread_), input_subsystem{std::move(input_subsystem_)}, system{system_} { + : QWidget(parent), emu_thread(emu_thread_), input_subsystem{std::move(input_subsystem_)}, + system{system_} { setWindowTitle(QStringLiteral("eden %1 | %2-%3") .arg(QString::fromUtf8(Common::g_build_name), QString::fromUtf8(Common::g_scm_branch), @@ -1122,9 +1122,21 @@ void GRenderWindow::OnEmulationStopping() { void GRenderWindow::showEvent(QShowEvent* event) { QWidget::showEvent(event); - // windowHandle() is not initialized until the Window is shown, so we connect it here. - connect(windowHandle(), &QWindow::screenChanged, this, &GRenderWindow::OnFramebufferSizeChanged, - Qt::UniqueConnection); + QWindow* window = windowHandle(); + if (!window) { + QWidget* nativeParent = nativeParentWidget(); + if (nativeParent) { + window = nativeParent->windowHandle(); + } + } + if (!window) { + LOG_ERROR(Frontend, "Failed to acquire QWindow pointer of GRenderWindow. ScreenChanged " + "signal not connected."); + } else { + // windowHandle() is not initialized until the Window is shown, so we connect it here. + connect(window, &QWindow::screenChanged, this, &GRenderWindow::OnFramebufferSizeChanged, + Qt::UniqueConnection); + } } bool GRenderWindow::eventFilter(QObject* object, QEvent* event) {