diff --git a/Source/Core/DolphinQt/Config/GameConfigEdit.cpp b/Source/Core/DolphinQt/Config/GameConfigEdit.cpp index be6587b009..705f3c6acc 100644 --- a/Source/Core/DolphinQt/Config/GameConfigEdit.cpp +++ b/Source/Core/DolphinQt/Config/GameConfigEdit.cpp @@ -63,7 +63,7 @@ GameConfigEdit::GameConfigEdit(QWidget* parent, const QString& path, bool read_o m_completer = new QCompleter(m_edit); - auto* completion_model = new QStringListModel; + auto* completion_model = new QStringListModel(m_completer); completion_model->setStringList(m_completions); m_completer->setModel(completion_model); @@ -77,8 +77,6 @@ GameConfigEdit::GameConfigEdit(QWidget* parent, const QString& path, bool read_o void GameConfigEdit::CreateWidgets() { - m_menu = new QMenu; - m_edit = new QTextEdit; m_edit->setReadOnly(m_read_only); m_edit->setAcceptRichText(false); @@ -89,6 +87,8 @@ void GameConfigEdit::CreateWidgets() menu_button->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); menu_button->setText(tr("Presets")); + + m_menu = new QMenu(menu_button); menu_button->setMenu(m_menu); layout->addWidget(menu_button); diff --git a/Source/Core/DolphinQt/Config/InfoWidget.cpp b/Source/Core/DolphinQt/Config/InfoWidget.cpp index faabe71747..7e165a33d8 100644 --- a/Source/Core/DolphinQt/Config/InfoWidget.cpp +++ b/Source/Core/DolphinQt/Config/InfoWidget.cpp @@ -104,7 +104,7 @@ QGroupBox* InfoWidget::CreateBannerDetails() m_name = CreateValueDisplay(); m_maker = CreateValueDisplay(); - m_description = new QTextEdit(); + m_description = new QTextEdit(group); m_description->setReadOnly(true); CreateLanguageSelector(); @@ -153,7 +153,7 @@ void InfoWidget::SaveBanner() QLineEdit* InfoWidget::CreateValueDisplay(const QString& value) { - QLineEdit* value_display = new QLineEdit(value); + QLineEdit* value_display = new QLineEdit(value, this); value_display->setReadOnly(true); value_display->setCursorPosition(0); return value_display; diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp index 50e2bd2991..27ebc2ef79 100644 --- a/Source/Core/DolphinQt/GameList/GameList.cpp +++ b/Source/Core/DolphinQt/GameList/GameList.cpp @@ -196,7 +196,7 @@ void GameList::MakeEmptyView() "Double-click here to set a games directory...")); m_empty->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); - auto event_filter = new DoubleClickEventFilter{}; + auto event_filter = new DoubleClickEventFilter{m_empty}; m_empty->installEventFilter(event_filter); connect(event_filter, &DoubleClickEventFilter::doubleClicked, [this] { auto current_dir = QDir::currentPath(); diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 022252e6d3..f4526ee49c 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -323,7 +323,7 @@ void MainWindow::InitCoreCallbacks() static void InstallHotkeyFilter(QWidget* dialog) { - auto* filter = new WindowActivationEventFilter(); + auto* filter = new WindowActivationEventFilter(dialog); dialog->installEventFilter(filter); filter->connect(filter, &WindowActivationEventFilter::windowDeactivated, diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index 0c872c4aef..2ff5dfcc5c 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -271,7 +271,7 @@ void MenuBar::AddToolsMenu() m_perform_online_update_menu->addAction(tr("United States"), this, [this] { emit PerformOnlineUpdate("USA"); }); - QMenu* menu = new QMenu(tr("Connect Wii Remotes")); + QMenu* menu = new QMenu(tr("Connect Wii Remotes"), tools_menu); tools_menu->addSeparator(); tools_menu->addMenu(menu); diff --git a/Source/Core/DolphinQt/QtUtils/DoubleClickEventFilter.cpp b/Source/Core/DolphinQt/QtUtils/DoubleClickEventFilter.cpp index 993da44f62..7a9b8cf1de 100644 --- a/Source/Core/DolphinQt/QtUtils/DoubleClickEventFilter.cpp +++ b/Source/Core/DolphinQt/QtUtils/DoubleClickEventFilter.cpp @@ -6,6 +6,10 @@ #include "DolphinQt/QtUtils/DoubleClickEventFilter.h" +DoubleClickEventFilter::DoubleClickEventFilter(QObject* parent) : QObject(parent) +{ +} + bool DoubleClickEventFilter::eventFilter(QObject* object, QEvent* event) { if (event->type() == QEvent::MouseButtonDblClick) diff --git a/Source/Core/DolphinQt/QtUtils/DoubleClickEventFilter.h b/Source/Core/DolphinQt/QtUtils/DoubleClickEventFilter.h index 1e2da4a960..548262bd88 100644 --- a/Source/Core/DolphinQt/QtUtils/DoubleClickEventFilter.h +++ b/Source/Core/DolphinQt/QtUtils/DoubleClickEventFilter.h @@ -9,6 +9,9 @@ class DoubleClickEventFilter : public QObject { Q_OBJECT +public: + explicit DoubleClickEventFilter(QObject* parent); + signals: void doubleClicked(); diff --git a/Source/Core/DolphinQt/QtUtils/WindowActivationEventFilter.cpp b/Source/Core/DolphinQt/QtUtils/WindowActivationEventFilter.cpp index 74907c46d6..a3819e24b4 100644 --- a/Source/Core/DolphinQt/QtUtils/WindowActivationEventFilter.cpp +++ b/Source/Core/DolphinQt/QtUtils/WindowActivationEventFilter.cpp @@ -7,6 +7,10 @@ #include "DolphinQt/QtUtils/WindowActivationEventFilter.h" +WindowActivationEventFilter::WindowActivationEventFilter(QObject* parent) : QObject(parent) +{ +} + bool WindowActivationEventFilter::eventFilter(QObject* object, QEvent* event) { if (event->type() == QEvent::WindowDeactivate) diff --git a/Source/Core/DolphinQt/QtUtils/WindowActivationEventFilter.h b/Source/Core/DolphinQt/QtUtils/WindowActivationEventFilter.h index c48e239540..49c467c8be 100644 --- a/Source/Core/DolphinQt/QtUtils/WindowActivationEventFilter.h +++ b/Source/Core/DolphinQt/QtUtils/WindowActivationEventFilter.h @@ -9,6 +9,9 @@ class WindowActivationEventFilter : public QObject { Q_OBJECT +public: + explicit WindowActivationEventFilter(QObject* parent); + signals: void windowActivated(); void windowDeactivated(); diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index d1fa694fae..fe9e31dc21 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -16,6 +16,7 @@ #include "Common/Flag.h" #include "Common/Logging/Log.h" #include "Common/MathUtil.h" +#include "Common/ScopeGuard.h" #include "Common/StringUtil.h" #include "Common/Thread.h" #include "InputCommon/ControllerInterface/ControllerInterface.h" @@ -40,10 +41,14 @@ static void HotplugThreadFunc() NOTICE_LOG(SERIALINTERFACE, "evdev hotplug thread started"); udev* const udev = udev_new(); + Common::ScopeGuard udev_guard([udev] { udev_unref(udev); }); + ASSERT_MSG(PAD, udev != nullptr, "Couldn't initialize libudev."); // Set up monitoring udev_monitor* const monitor = udev_monitor_new_from_netlink(udev, "udev"); + Common::ScopeGuard monitor_guard([monitor] { udev_monitor_unref(monitor); }); + udev_monitor_filter_add_match_subsystem_devtype(monitor, "input", nullptr); udev_monitor_enable_receiving(monitor); const int monitor_fd = udev_monitor_get_fd(monitor); @@ -61,11 +66,11 @@ static void HotplugThreadFunc() if (ret < 1 || !FD_ISSET(monitor_fd, &fds)) continue; - std::unique_ptr dev{ - udev_monitor_receive_device(monitor), udev_device_unref}; + udev_device* const dev = udev_monitor_receive_device(monitor); + Common::ScopeGuard dev_guard([dev] { udev_device_unref(dev); }); - const char* const action = udev_device_get_action(dev.get()); - const char* const devnode = udev_device_get_devnode(dev.get()); + const char* const action = udev_device_get_action(dev); + const char* const devnode = udev_device_get_devnode(dev); if (!devnode) continue;