aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorIvan Komissarov <ABBAPOH@gmail.com>2019-05-03 19:37:53 +0200
committerIvan Komissarov <ABBAPOH@gmail.com>2019-05-08 07:55:17 +0000
commit0c7fc9258c3c7eae06e79281caf6adb54f31d895 (patch)
treeb9215f464c626fd5758eabcbf94a5a4b16e0015e /src/lib
parentbc7511d79df113777a397bcca975f180cef9c10d (diff)
Use std::unique_ptr in PropertyMap
This makes move ctors and destructor trivial Change-Id: Ifee00b7526fd1564fcf01f799230997f929b29db Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/corelib/api/projectdata.cpp26
-rw-r--r--src/lib/corelib/api/projectdata.h3
2 files changed, 9 insertions, 20 deletions
diff --git a/src/lib/corelib/api/projectdata.cpp b/src/lib/corelib/api/projectdata.cpp
index 0cac7553b..1b40916a1 100644
--- a/src/lib/corelib/api/projectdata.cpp
+++ b/src/lib/corelib/api/projectdata.cpp
@@ -828,41 +828,29 @@ bool operator<(const ProjectData &lhs, const ProjectData &rhs)
*/
PropertyMap::PropertyMap()
- : d(new Internal::PropertyMapPrivate)
+ : d(std::make_unique<Internal::PropertyMapPrivate>())
{
static Internal::PropertyMapPtr defaultInternalMap = Internal::PropertyMapInternal::create();
d->m_map = defaultInternalMap;
}
PropertyMap::PropertyMap(const PropertyMap &other)
- : d(new Internal::PropertyMapPrivate(*other.d))
+ : d(std::make_unique<Internal::PropertyMapPrivate>(*other.d))
{
}
-PropertyMap::PropertyMap(PropertyMap &&other) Q_DECL_NOEXCEPT
-{
- std::swap(d, other.d);
-}
+PropertyMap::PropertyMap(PropertyMap &&other) Q_DECL_NOEXCEPT = default;
-PropertyMap::~PropertyMap()
-{
- delete d;
-}
+PropertyMap::~PropertyMap() = default;
PropertyMap &PropertyMap::operator =(const PropertyMap &other)
{
- if (this != &other) {
- delete d;
- d = new Internal::PropertyMapPrivate(*other.d);
- }
+ if (this != &other)
+ d = std::make_unique<Internal::PropertyMapPrivate>(*other.d);
return *this;
}
-PropertyMap &PropertyMap::operator =(PropertyMap &&other) Q_DECL_NOEXCEPT
-{
- std::swap(d, other.d);
- return *this;
-}
+PropertyMap &PropertyMap::operator =(PropertyMap &&other) Q_DECL_NOEXCEPT = default;
/*!
* \brief Returns the names of all properties.
diff --git a/src/lib/corelib/api/projectdata.h b/src/lib/corelib/api/projectdata.h
index 2bb1419d5..3bd1c4540 100644
--- a/src/lib/corelib/api/projectdata.h
+++ b/src/lib/corelib/api/projectdata.h
@@ -48,6 +48,7 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qvariant.h>
+#include <memory>
#include <utility>
namespace qbs {
@@ -92,7 +93,7 @@ public:
QString toString() const;
private:
- Internal::PropertyMapPrivate *d = nullptr;
+ std::unique_ptr<Internal::PropertyMapPrivate> d;
};
class InstallData;