Qt: Fix use-after-free in shader settings

This commit is contained in:
Adam Higerd 2025-02-12 18:02:34 -06:00 committed by Vicki Pfau
parent 7607a5bea9
commit 8c98eafc77
2 changed files with 5 additions and 4 deletions

View File

@ -437,9 +437,9 @@ void SettingsView::setShaderSelector(ShaderSelector* shaderSelector) {
QObject::disconnect(m_shader, nullptr, this, nullptr);
}
m_shader = shaderSelector;
QObject::connect(this, &SettingsView::saveSettingsRequested, m_shader, &ShaderSelector::saveSettings);
QObject::connect(m_ui.buttonBox, &QDialogButtonBox::rejected, m_shader, &ShaderSelector::revert);
if (shaderSelector) {
QObject::connect(this, &SettingsView::saveSettingsRequested, m_shader, &ShaderSelector::saveSettings);
QObject::connect(m_ui.buttonBox, &QDialogButtonBox::rejected, m_shader, &ShaderSelector::revert);
addPage(tr("Shaders"), m_shader, Page::SHADERS);
} else {
addPage(tr("Shaders"), m_dummyShader, Page::SHADERS);

View File

@ -7,10 +7,12 @@
#include <QDialog>
#include <QMap>
#include <QPointer>
#include <QTimer>
#include "ColorPicker.h"
#include "LogConfigModel.h"
#include "ShaderSelector.h"
#include <mgba/core/core.h>
@ -25,7 +27,6 @@ namespace QGBA {
class ConfigController;
class InputController;
class ShortcutController;
class ShaderSelector;
class SettingsView : public QDialog {
Q_OBJECT
@ -80,7 +81,7 @@ private:
ConfigController* m_controller;
InputController* m_input;
ShaderSelector* m_shader = nullptr;
QPointer<ShaderSelector> m_shader;
QLabel* m_dummyShader;
LogConfigModel m_logModel;
QTimer m_checkTimer;