From 11e0a4fc5e44097abe8e082f447f715e06c6121a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 21 Jun 2023 07:44:10 +0200 Subject: [PATCH] QMessageBox: use optional<> instead of unique_ptr ... to hold the optional QApplication. Saves a memory allocation, and is more readable. Amends 408fbd3f2d7a6b87521f5b3c27ecf6341dc06e13. Change-Id: I390b9cfa367d01feb59bb5deadc5383c8e678749 Reviewed-by: Axel Spoerl (cherry picked from commit 2389b93b7991e96dc189e44cf5ea7ca894224d30) Reviewed-by: Qt Cherry-pick Bot --- src/widgets/dialogs/qmessagebox.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 0e7ef44808f..b6094372e00 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -39,7 +39,7 @@ #include #endif -#include +#include QT_BEGIN_NAMESPACE @@ -2853,9 +2853,9 @@ Q_WIDGETS_EXPORT void _q_requireVersion(int argc, char *argv[], QAnyStringView r const auto current = QVersionNumber::fromString(qVersion()).normalized(); if (current >= required) return; - std::unique_ptr application; + std::optional application; if (!qApp) - application = std::make_unique(argc, argv); + application.emplace(argc, argv); const QString message = QApplication::tr("Application \"%1\" requires Qt %2, found Qt %3.") .arg(qAppName(), required.toString(), current.toString()); QMessageBox::critical(nullptr, QApplication::tr("Incompatible Qt Library Error"),