diff options
author | Marc Mutz <[email protected]> | 2024-12-31 10:03:41 +0100 |
---|---|---|
committer | Marc Mutz <[email protected]> | 2025-01-02 07:50:57 +0100 |
commit | 0da2c2c4ef2219967db87021eece2a60b6e207af (patch) | |
tree | fc68cf81cb463b075f1855efd59bfed8b4789c9a /examples/sql/sqlbrowser/qsqlconnectiondialog.cpp | |
parent | 9c099ef942216d01261c26b60e3727a2a467f12a (diff) |
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 <[email protected]>
Diffstat (limited to 'examples/sql/sqlbrowser/qsqlconnectiondialog.cpp')
-rw-r--r-- | examples/sql/sqlbrowser/qsqlconnectiondialog.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
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<Ui::QSqlConnectionDialogUi>()} { m_ui->setupUi(this); @@ -24,9 +24,7 @@ QSqlConnectionDialog::QSqlConnectionDialog(QWidget *parent) } QSqlConnectionDialog::~QSqlConnectionDialog() -{ - delete m_ui; -} + = default; QString QSqlConnectionDialog::driverName() const { |