QLocalServer/Unix: don't allocate QTemporaryDir just to make it optional<>

Use std::optional<> instead.

Change-Id: Ic33ae2dd71f2b6c4347dac7c4be4dc6227edf425
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Marc Mutz 2021-06-25 16:10:31 +02:00
parent 3552821551
commit 82bc752497

View File

@ -52,6 +52,8 @@
#include <qdir.h>
#include <qdatetime.h>
#include <optional>
#ifdef Q_OS_VXWORKS
# include <selectLib.h>
#endif
@ -113,11 +115,11 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
QByteArray encodedTempPath;
const QByteArray encodedFullServerName = QFile::encodeName(fullServerName);
QScopedPointer<QTemporaryDir> tempDir;
std::optional<QTemporaryDir> tempDir;
if (options & QLocalServer::WorldAccessOption) {
QFileInfo serverNameFileInfo(fullServerName);
tempDir.reset(new QTemporaryDir(serverNameFileInfo.absolutePath() + QLatin1Char('/')));
tempDir.emplace(serverNameFileInfo.absolutePath() + u'/');
if (!tempDir->isValid()) {
setError(QLatin1String("QLocalServer::listen"));
return false;