Skip to content

Commit

Permalink
DolphinQt2/MainWindow: Resolve a memory leak on systems with X11
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lioncash committed Apr 5, 2018
1 parent d0b7c01 commit 839fc7e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Source/Core/DolphinQt2/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Display*>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow(
"display", windowHandle())),
winId()),
this);
m_xrr_config = std::make_unique<X11Utils::XRRConfiguration>(
static_cast<Display*>(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
Expand Down
9 changes: 9 additions & 0 deletions Source/Core/DolphinQt2/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class SettingsWindow;
class WatchWidget;
class WiiTASInputWindow;

namespace X11Utils
{
class XRRConfiguration;
}

class MainWindow final : public QMainWindow
{
Q_OBJECT
Expand Down Expand Up @@ -146,6 +151,10 @@ class MainWindow final : public QMainWindow
void dropEvent(QDropEvent* event) override;
QSize sizeHint() const override;

#if defined(HAVE_XRANDR) && HAVE_XRANDR
std::unique_ptr<X11Utils::XRRConfiguration> m_xrr_config;
#endif

QProgressDialog* m_progress_dialog = nullptr;
QStackedWidget* m_stack;
ToolBar* m_tool_bar;
Expand Down

0 comments on commit 839fc7e

Please sign in to comment.