diff options
author | Yuri Gorshenin <ygorshenin@chromium.org> | 2015-03-11 18:48:58 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:38:48 +0300 |
commit | 8fdbf7ad9730aeaf152f8956e76c495368954b9d (patch) | |
tree | 21563aebe2bba51e51b7fe3546a47d0c6c4bb5f8 /map/user_mark.hpp | |
parent | 1ab260d29a389dda2daebc258ae29f97c19bd6c8 (diff) |
[bookmark] Fixed memory leaks in UserMarkCopy.
Diffstat (limited to 'map/user_mark.hpp')
-rw-r--r-- | map/user_mark.hpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/map/user_mark.hpp b/map/user_mark.hpp index 5bf34c0db3..0218bcb019 100644 --- a/map/user_mark.hpp +++ b/map/user_mark.hpp @@ -6,8 +6,9 @@ #include "../search/result.hpp" -#include "../std/string.hpp" #include "../std/noncopyable.hpp" +#include "../std/string.hpp" +#include "../std/unique_ptr.hpp" class UserMarkContainer; class PaintOverlayEvent; @@ -40,7 +41,7 @@ public: void GetLatLon(double & lat, double & lon) const; virtual bool IsCustomDrawable() const { return false;} virtual Type GetMarkType() const = 0; - virtual UserMarkCopy * Copy() const = 0; + virtual unique_ptr<UserMarkCopy> Copy() const = 0; protected: m2::PointD m_ptOrg; @@ -95,9 +96,10 @@ public: string const & GetID() const { return m_id; } void SetID(string const & id) { m_id = id; } - virtual UserMarkCopy * Copy() const + unique_ptr<UserMarkCopy> Copy() const override { - return new UserMarkCopy(new ApiMarkPoint(m_name, m_id, m_ptOrg, m_container)); + return unique_ptr<UserMarkCopy>( + new UserMarkCopy(new ApiMarkPoint(m_name, m_id, m_ptOrg, m_container))); } private: @@ -129,9 +131,10 @@ public: feature::FeatureMetadata const & GetMetadata() const { return m_metadata; } void SetMetadata(feature::FeatureMetadata const & metadata) { m_metadata = metadata; } - virtual UserMarkCopy * Copy() const + unique_ptr<UserMarkCopy> Copy() const override { - return new UserMarkCopy(new SearchMarkPoint(m_info, m_ptOrg, m_container)); + return unique_ptr<UserMarkCopy>( + new UserMarkCopy(new SearchMarkPoint(m_info, m_ptOrg, m_container))); } protected: @@ -146,9 +149,9 @@ public: : SearchMarkPoint(m2::PointD(0.0, 0.0), container) {} UserMark::Type GetMarkType() const { return POI; } - virtual UserMarkCopy * Copy() const + unique_ptr<UserMarkCopy> Copy() const override { - return new UserMarkCopy(this, false); + return unique_ptr<UserMarkCopy>(new UserMarkCopy(this, false)); } void SetPtOrg(m2::PointD const & ptOrg) { m_ptOrg = ptOrg; } |