diff options
| author | 2016-04-18 04:12:48 -0400 | |
|---|---|---|
| committer | 2016-04-18 04:12:48 -0400 | |
| commit | 6e9a9ded1bed40af8460e1e212ba1fa9bf7f1f71 (patch) | |
| tree | 044f0bd8d5168802628d689b1a7c23111a661851 /src/kvilib | |
| parent | general: Fix a lot of things (diff) | |
| download | KVIrc-6e9a9ded1bed40af8460e1e212ba1fa9bf7f1f71.tar.gz KVIrc-6e9a9ded1bed40af8460e1e212ba1fa9bf7f1f71.tar.bz2 KVIrc-6e9a9ded1bed40af8460e1e212ba1fa9bf7f1f71.zip | |
KviIrcUserEntry: Make setAvatar accept unique_ptr
Diffstat (limited to 'src/kvilib')
| -rw-r--r-- | src/kvilib/irc/KviIrcUserEntry.cpp | 12 | ||||
| -rw-r--r-- | src/kvilib/irc/KviIrcUserEntry.h | 17 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/kvilib/irc/KviIrcUserEntry.cpp b/src/kvilib/irc/KviIrcUserEntry.cpp index 6e98268ce..e380ee176 100644 --- a/src/kvilib/irc/KviIrcUserEntry.cpp +++ b/src/kvilib/irc/KviIrcUserEntry.cpp @@ -93,12 +93,18 @@ void KviIrcUserEntry::setRealName(const QString & szReal) } } +void KviIrcUserEntry::setAvatar(std::unique_ptr<KviAvatar> upAvatar) +{ + m_upAvatar = std::move(upAvatar); +} + +// Overload function for backwards compatibility void KviIrcUserEntry::setAvatar(KviAvatar * pAvatar) { - m_pAvatar.reset(pAvatar); + m_upAvatar.reset(pAvatar); } -KviAvatar * KviIrcUserEntry::forgetAvatar() +std::unique_ptr<KviAvatar> KviIrcUserEntry::forgetAvatar() { - return m_pAvatar.release(); + return std::move(m_upAvatar); } diff --git a/src/kvilib/irc/KviIrcUserEntry.h b/src/kvilib/irc/KviIrcUserEntry.h index 3b4e8c997..890ec56f7 100644 --- a/src/kvilib/irc/KviIrcUserEntry.h +++ b/src/kvilib/irc/KviIrcUserEntry.h @@ -90,7 +90,7 @@ protected: bool m_bAway; bool m_bIrcOp; - std::unique_ptr<KviAvatar> m_pAvatar; + std::unique_ptr<KviAvatar> m_upAvatar; int m_nRefs; bool m_bBot; @@ -190,11 +190,20 @@ public: /** * \brief Sets the avatar of the user + * \param upAvatar The avatar + * \return void + * \warning The ownership passes to this class! + */ + void setAvatar(std::unique_ptr<KviAvatar> upAvatar = nullptr); + + /** + * \brief Sets the avatar of the user * \param pAvatar The avatar * \return void * \warning The ownership passes to this class! + * \warning This is an overload function for backwards compatibility */ - void setAvatar(KviAvatar * pAvatar = nullptr); + void setAvatar(KviAvatar * upAvatar = nullptr); /** * \brief Sets the user global flags (eg: "G*") @@ -291,7 +300,7 @@ public: * \brief Returns the avatar of the user * \return KviAvatar */ - KviAvatar * avatar(){ return m_pAvatar.get(); }; + KviAvatar * avatar(){ return m_upAvatar.get(); }; /** * \brief Returns the number of references of the user in the database @@ -303,7 +312,7 @@ public: * \brief Removes the avatar associated to the user * \return KviAvatar * */ - KviAvatar * forgetAvatar(); + std::unique_ptr<KviAvatar> forgetAvatar(); /** * \brief Returns true if kvirc already made an attempt to download user's avatar |
