From 839fc7e749af9504c6c8ee451c9d47dd32c0dbeb Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 5 Apr 2018 09:03:12 -0400 Subject: [PATCH] DolphinQt2/MainWindow: Resolve a memory leak on systems with X11 In the case we had X11 libs available, we'd allocate an XRRConfiguration instance and pass it to the GraphicsWindow instance, but it would never actually be freed. --- Source/Core/DolphinQt2/MainWindow.cpp | 11 +++++------ Source/Core/DolphinQt2/MainWindow.h | 9 +++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index 3ed8a30729..6d0c452050 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -221,12 +221,11 @@ void MainWindow::CreateComponents() &MemoryWidget::Update); #if defined(HAVE_XRANDR) && HAVE_XRANDR - m_graphics_window = new GraphicsWindow( - new X11Utils::XRRConfiguration( - static_cast(QGuiApplication::platformNativeInterface()->nativeResourceForWindow( - "display", windowHandle())), - winId()), - this); + m_xrr_config = std::make_unique( + static_cast(QGuiApplication::platformNativeInterface()->nativeResourceForWindow( + "display", windowHandle())), + winId()); + m_graphics_window = new GraphicsWindow(m_xrr_config.get(), this); #else m_graphics_window = new GraphicsWindow(nullptr, this); #endif diff --git a/Source/Core/DolphinQt2/MainWindow.h b/Source/Core/DolphinQt2/MainWindow.h index 8dfa24af74..aa660e2da9 100644 --- a/Source/Core/DolphinQt2/MainWindow.h +++ b/Source/Core/DolphinQt2/MainWindow.h @@ -43,6 +43,11 @@ class SettingsWindow; class WatchWidget; class WiiTASInputWindow; +namespace X11Utils +{ +class XRRConfiguration; +} + class MainWindow final : public QMainWindow { Q_OBJECT @@ -146,6 +151,10 @@ private: void dropEvent(QDropEvent* event) override; QSize sizeHint() const override; +#if defined(HAVE_XRANDR) && HAVE_XRANDR + std::unique_ptr m_xrr_config; +#endif + QProgressDialog* m_progress_dialog = nullptr; QStackedWidget* m_stack; ToolBar* m_tool_bar;