From 0da2c2c4ef2219967db87021eece2a60b6e207af Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 31 Dec 2024 10:03:41 +0100 Subject: sqlbrowser example: use unique_ptr to hold m_ui The old code used manual memory mangement (raw new/delete) to (de)allocate the Ui struct. This is so 80s. Use an owning smart pointer to manage the memory. Ordinarily, this would have been QScopedPointer, but seeing as that doesn't have a create() method to hide the raw new, use std::unique_ptr and std::make_unique() instead. Amends 2690822428deec4f0c08f4d118d69a7c6036369e. Pick-to: 6.9 6.8 Change-Id: Icabb9154eb38630855e14094b958af0214516f6b Reviewed-by: Volker Hilsheimer --- examples/sql/sqlbrowser/qsqlconnectiondialog.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'examples/sql/sqlbrowser/qsqlconnectiondialog.cpp') diff --git a/examples/sql/sqlbrowser/qsqlconnectiondialog.cpp b/examples/sql/sqlbrowser/qsqlconnectiondialog.cpp index 21c22b84d9b..9f6b8c8169a 100644 --- a/examples/sql/sqlbrowser/qsqlconnectiondialog.cpp +++ b/examples/sql/sqlbrowser/qsqlconnectiondialog.cpp @@ -11,7 +11,7 @@ QSqlConnectionDialog::QSqlConnectionDialog(QWidget *parent) : QDialog(parent) - , m_ui(new Ui::QSqlConnectionDialogUi) + , m_ui{std::make_unique()} { m_ui->setupUi(this); @@ -24,9 +24,7 @@ QSqlConnectionDialog::QSqlConnectionDialog(QWidget *parent) } QSqlConnectionDialog::~QSqlConnectionDialog() -{ - delete m_ui; -} + = default; QString QSqlConnectionDialog::driverName() const { -- cgit v1.2.3