summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-06-21 07:44:10 +0200
committerMarc Mutz <marc.mutz@qt.io>2023-06-21 13:58:02 +0200
commit2389b93b7991e96dc189e44cf5ea7ca894224d30 (patch)
treee81f023f83ec95b658f1a2a89414a956879dd14e /src/widgets/dialogs
parent1e626c135b7376bdbc6b2a27124afe66a802dfb0 (diff)
QMessageBox: use optional<> instead of unique_ptr
... to hold the optional QApplication. Saves a memory allocation, and is more readable. Amends 408fbd3f2d7a6b87521f5b3c27ecf6341dc06e13. Pick-to: 6.6 Change-Id: I390b9cfa367d01feb59bb5deadc5383c8e678749 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index 0e7ef44808..b6094372e0 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -39,7 +39,7 @@
#include <qpa/qplatformnativeinterface.h>
#endif
-#include <memory>
+#include <optional>
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<QApplication> application;
+ std::optional<QApplication> application;
if (!qApp)
- application = std::make_unique<QApplication>(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"),