diff options
author | Vincent Richard <[email protected]> | 2005-09-01 22:33:21 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2005-09-01 22:33:21 +0000 |
commit | 5c3e21ee1d687f3296f1c0c10621d4395dff1d36 (patch) | |
tree | 59d1565b6eceebf061fc11a9e0bd97dfe884a463 | |
parent | Added a menu entry to change current folder. (diff) | |
download | vmime-5c3e21ee1d687f3296f1c0c10621d4395dff1d36.tar.gz vmime-5c3e21ee1d687f3296f1c0c10621d4395dff1d36.zip |
NEVER call thisRef() from the object's constructor.
-rw-r--r-- | src/net/imap/IMAPMessage.cpp | 24 | ||||
-rw-r--r-- | vmime/object.hpp | 4 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/net/imap/IMAPMessage.cpp b/src/net/imap/IMAPMessage.cpp index 0d9e5e00..3dd6c021 100644 --- a/src/net/imap/IMAPMessage.cpp +++ b/src/net/imap/IMAPMessage.cpp @@ -45,8 +45,8 @@ private: friend class vmime::creator; - IMAPpart(weak_ref <IMAPpart> parent, const int number, const IMAPParser::body_type_mpart* mpart); - IMAPpart(weak_ref <IMAPpart> parent, const int number, const IMAPParser::body_type_1part* part); + IMAPpart(ref <IMAPpart> parent, const int number, const IMAPParser::body_type_mpart* mpart); + IMAPpart(ref <IMAPpart> parent, const int number, const IMAPParser::body_type_1part* part); public: @@ -69,12 +69,19 @@ public: static ref <IMAPpart> create - (weak_ref <IMAPpart> parent, const int number, const IMAPParser::body* body) + (ref <IMAPpart> parent, const int number, const IMAPParser::body* body) { if (body->body_type_mpart()) - return vmime::create <IMAPpart>(parent, number, body->body_type_mpart()); + { + ref <IMAPpart> part = vmime::create <IMAPpart>(parent, number, body->body_type_mpart()); + part->m_structure = vmime::create <IMAPstructure>(part, body->body_type_mpart()->list()); + + return part; + } else + { return vmime::create <IMAPpart>(parent, number, body->body_type_1part()); + } } @@ -118,7 +125,7 @@ public: m_parts.push_back(IMAPpart::create(NULL, 1, body)); } - IMAPstructure(weak_ref <IMAPpart> parent, const std::vector <IMAPParser::body*>& list) + IMAPstructure(ref <IMAPpart> parent, const std::vector <IMAPParser::body*>& list) { int number = 1; @@ -163,18 +170,15 @@ IMAPstructure IMAPstructure::m_emptyStructure; -IMAPpart::IMAPpart(weak_ref <IMAPpart> parent, const int number, const IMAPParser::body_type_mpart* mpart) +IMAPpart::IMAPpart(ref <IMAPpart> parent, const int number, const IMAPParser::body_type_mpart* mpart) : m_parent(parent), m_header(NULL), m_number(number), m_size(0) { m_mediaType = vmime::mediaType ("multipart", mpart->media_subtype()->value()); - - m_structure = vmime::create <IMAPstructure> - (thisWeakRef().dynamicCast <IMAPpart>(), mpart->list()); } -IMAPpart::IMAPpart(weak_ref <IMAPpart> parent, const int number, const IMAPParser::body_type_1part* part) +IMAPpart::IMAPpart(ref <IMAPpart> parent, const int number, const IMAPParser::body_type_1part* part) : m_parent(parent), m_header(NULL), m_number(number), m_size(0) { if (part->body_type_text()) diff --git a/vmime/object.hpp b/vmime/object.hpp index 471670df..0ef6e199 100644 --- a/vmime/object.hpp +++ b/vmime/object.hpp @@ -69,24 +69,28 @@ protected: void releaseWeak(utility::weak_ref_base* w) const; /** Return a reference to this object. + * \warning NEVER CALL THIS FROM A CONSTRUCTOR! * * @return reference to self */ ref <object> thisRef(); /** Return a reference to this object (const version). + * \warning NEVER CALL THIS FROM A CONSTRUCTOR! * * @return reference to self */ ref <const object> thisRef() const; /** Return a weak reference to this object. + * \warning NEVER CALL THIS FROM A CONSTRUCTOR! * * @return weak reference to self */ weak_ref <object> thisWeakRef(); /** Return a weak reference to this object (const version). + * \warning NEVER CALL THIS FROM A CONSTRUCTOR! * * @return weak reference to self */ |