Replace QScopedPointer with std::unqiue_ptr

These 2 types are very similar and we should prefer the one from C++
standard library, this reduces the number of types in our code base.

Also see:
https://stackoverflow.com/questions/40346393/should-i-use-qscopedpointer-or-stdunique-ptr#comment67966940_40346991
This commit is contained in:
Chocobo1
2019-02-16 12:29:57 +08:00
parent 78ab0e4ba9
commit 5e3fddf456
7 changed files with 18 additions and 16 deletions

View File

@@ -29,8 +29,6 @@
#include "profile.h"
#include <QCoreApplication>
#include "private/profile_p.h"
Profile *Profile::m_instance = nullptr;
@@ -50,14 +48,14 @@ Profile::~Profile() = default;
void Profile::initialize(const QString &rootProfilePath, const QString &configurationName,
bool convertPathsToProfileRelative)
{
QScopedPointer<Private::Profile> profile(rootProfilePath.isEmpty()
std::unique_ptr<Private::Profile> profile(rootProfilePath.isEmpty()
? static_cast<Private::Profile *>(new Private::DefaultProfile(configurationName))
: static_cast<Private::Profile *>(new Private::CustomProfile(rootProfilePath, configurationName)));
QScopedPointer<Private::PathConverter> converter(convertPathsToProfileRelative
std::unique_ptr<Private::PathConverter> converter(convertPathsToProfileRelative
? static_cast<Private::PathConverter *>(new Private::Converter(profile->baseDirectory()))
: static_cast<Private::PathConverter *>(new Private::NoConvertConverter()));
m_instance = new Profile(profile.take(), converter.take());
m_instance = new Profile(profile.release(), converter.release());
}
const Profile &Profile::instance()