From ffd2fee26ab62003946ff89a2e365eae0b8214ac Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Tue, 12 Feb 2019 10:42:39 +0100 Subject: [PATCH] ClangTools: Use std::unique_ptr in DiagnosticView Change-Id: Iee8faf18178b6190b4d8b2bc2816ea00d680bd3f Reviewed-by: Ivan Donchevskii --- src/plugins/clangtools/clangtoolsdiagnosticview.cpp | 12 ++++-------- src/plugins/clangtools/clangtoolsdiagnosticview.h | 6 ++++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/plugins/clangtools/clangtoolsdiagnosticview.cpp b/src/plugins/clangtools/clangtoolsdiagnosticview.cpp index 11767825a11..33b002ced25 100644 --- a/src/plugins/clangtools/clangtoolsdiagnosticview.cpp +++ b/src/plugins/clangtools/clangtoolsdiagnosticview.cpp @@ -178,22 +178,18 @@ private: DiagnosticView::DiagnosticView(QWidget *parent) : Debugger::DetailedErrorView(parent) , m_style(new DiagnosticViewStyle) - , m_delegate(new DiagnosticViewDelegate(m_style)) + , m_delegate(new DiagnosticViewDelegate(m_style.get())) { m_suppressAction = new QAction(tr("Suppress This Diagnostic"), this); connect(m_suppressAction, &QAction::triggered, this, &DiagnosticView::suppressCurrentDiagnostic); installEventFilter(this); - setStyle(m_style); - setItemDelegate(m_delegate); + setStyle(m_style.get()); + setItemDelegate(m_delegate.get()); } -DiagnosticView::~DiagnosticView() -{ - delete m_delegate; - delete m_style; -} +DiagnosticView::~DiagnosticView() = default; void DiagnosticView::suppressCurrentDiagnostic() { diff --git a/src/plugins/clangtools/clangtoolsdiagnosticview.h b/src/plugins/clangtools/clangtoolsdiagnosticview.h index 8580b93b734..6bc61351016 100644 --- a/src/plugins/clangtools/clangtoolsdiagnosticview.h +++ b/src/plugins/clangtools/clangtoolsdiagnosticview.h @@ -27,6 +27,8 @@ #include +#include + namespace ClangTools { namespace Internal { @@ -59,8 +61,8 @@ private: void setModel(QAbstractItemModel *theProxyModel) override; QAction *m_suppressAction; - DiagnosticViewStyle *m_style = nullptr; - DiagnosticViewDelegate *m_delegate = nullptr; + std::unique_ptr m_style; + std::unique_ptr m_delegate; bool m_ignoreSetSelectedFixItsCount = false; };