From 6e14dcf70add539dc40ae32eee4df312dbd52c14 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 30 Jul 2019 18:27:06 -0400 Subject: [PATCH] DolphinQt/Config/GameConfigEdit: Pass parent pointer to base class Previously, the constructor of GameConfigEdit wasn't doing anything with the passed in parent pointer. This is dangerous because it can result in memory being leaked in certain scenarios. It can also affect layout decisions made by the parent. Instead, pass it through to the base class. Current usages of the class pass in nullptr as the parent, so this is a safe change to make with regards to the class hierarchy. While we're at it, we can std::move the passed in QString into the class member, allowing calling code to move strings into the constructor, avoiding copies. --- Source/Core/DolphinQt/Config/GameConfigEdit.cpp | 4 ++-- Source/Core/DolphinQt/Config/GameConfigEdit.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinQt/Config/GameConfigEdit.cpp b/Source/Core/DolphinQt/Config/GameConfigEdit.cpp index 9598abb5c1..c61a425fcc 100644 --- a/Source/Core/DolphinQt/Config/GameConfigEdit.cpp +++ b/Source/Core/DolphinQt/Config/GameConfigEdit.cpp @@ -21,8 +21,8 @@ #include "DolphinQt/Config/GameConfigHighlighter.h" #include "DolphinQt/QtUtils/ModalMessageBox.h" -GameConfigEdit::GameConfigEdit(QWidget* parent, const QString& path, bool read_only) - : m_path(path), m_read_only(read_only) +GameConfigEdit::GameConfigEdit(QWidget* parent, QString path, bool read_only) + : QWidget{parent}, m_path(std::move(path)), m_read_only(read_only) { CreateWidgets(); diff --git a/Source/Core/DolphinQt/Config/GameConfigEdit.h b/Source/Core/DolphinQt/Config/GameConfigEdit.h index 7eeca57b2d..203762c66d 100644 --- a/Source/Core/DolphinQt/Config/GameConfigEdit.h +++ b/Source/Core/DolphinQt/Config/GameConfigEdit.h @@ -16,7 +16,7 @@ class QTextEdit; class GameConfigEdit : public QWidget { public: - explicit GameConfigEdit(QWidget* parent, const QString& path, bool read_only); + explicit GameConfigEdit(QWidget* parent, QString path, bool read_only); protected: void keyPressEvent(QKeyEvent* e) override;