diff --git a/src/kcmkwin/kwinrules/ruleitem.cpp b/src/kcmkwin/kwinrules/ruleitem.cpp index 50bae6aa36..2ddfd066ae 100644 --- a/src/kcmkwin/kwinrules/ruleitem.cpp +++ b/src/kcmkwin/kwinrules/ruleitem.cpp @@ -24,18 +24,11 @@ RuleItem::RuleItem(const QString &key, , m_description(description) , m_flags(NoFlags) , m_enabled(false) - , m_policy(new RulePolicy(policyType)) - , m_options(nullptr) + , m_policy(std::make_unique(policyType)) { reset(); } -RuleItem::~RuleItem() -{ - delete m_policy; - delete m_options; -} - void RuleItem::reset() { m_enabled = hasFlag(AlwaysEnabled) || hasFlag(StartEnabled); @@ -133,7 +126,7 @@ QVariant RuleItem::options() const if (!m_options) { return QVariant(); } - return QVariant::fromValue(m_options); + return QVariant::fromValue(m_options.get()); } void RuleItem::setOptionsData(const QList &data) @@ -142,7 +135,7 @@ void RuleItem::setOptionsData(const QList &data) return; } if (!m_options) { - m_options = new OptionsModel({}, m_type == NetTypes); + m_options = std::make_unique(QList{}, m_type == NetTypes); } m_options->updateModelData(data); m_options->setValue(m_value); @@ -165,7 +158,7 @@ RulePolicy::Type RuleItem::policyType() const QVariant RuleItem::policyModel() const { - return QVariant::fromValue(m_policy); + return QVariant::fromValue(m_policy.get()); } QString RuleItem::policyKey() const diff --git a/src/kcmkwin/kwinrules/ruleitem.h b/src/kcmkwin/kwinrules/ruleitem.h index 2a126cc8c4..f8672ce17c 100644 --- a/src/kcmkwin/kwinrules/ruleitem.h +++ b/src/kcmkwin/kwinrules/ruleitem.h @@ -54,7 +54,6 @@ public: const QString §ion, const QIcon &icon = QIcon::fromTheme("window"), const QString &description = QString("")); - ~RuleItem(); QString key() const; QString name() const; @@ -103,8 +102,8 @@ private: QVariant m_value; QVariant m_suggestedValue; - RulePolicy *m_policy; - OptionsModel *m_options; + std::unique_ptr m_policy; + std::unique_ptr m_options; }; } // namespace