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 <axel.spoerl@qt.io> (cherry picked from commit 2389b93b7991e96dc189e44cf5ea7ca894224d30) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
1c79aab50d
commit
11e0a4fc5e
@ -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"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user