From 5c3e21ee1d687f3296f1c0c10621d4395dff1d36 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 1 Sep 2005 22:33:21 +0000 Subject: [PATCH] NEVER call thisRef() from the object's constructor. --- src/net/imap/IMAPMessage.cpp | 24 ++++++++++++++---------- 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 parent, const int number, const IMAPParser::body_type_mpart* mpart); - IMAPpart(weak_ref parent, const int number, const IMAPParser::body_type_1part* part); + IMAPpart(ref parent, const int number, const IMAPParser::body_type_mpart* mpart); + IMAPpart(ref parent, const int number, const IMAPParser::body_type_1part* part); public: @@ -69,12 +69,19 @@ public: static ref create - (weak_ref parent, const int number, const IMAPParser::body* body) + (ref parent, const int number, const IMAPParser::body* body) { if (body->body_type_mpart()) - return vmime::create (parent, number, body->body_type_mpart()); + { + ref part = vmime::create (parent, number, body->body_type_mpart()); + part->m_structure = vmime::create (part, body->body_type_mpart()->list()); + + return part; + } else + { return vmime::create (parent, number, body->body_type_1part()); + } } @@ -118,7 +125,7 @@ public: m_parts.push_back(IMAPpart::create(NULL, 1, body)); } - IMAPstructure(weak_ref parent, const std::vector & list) + IMAPstructure(ref parent, const std::vector & list) { int number = 1; @@ -163,18 +170,15 @@ IMAPstructure IMAPstructure::m_emptyStructure; -IMAPpart::IMAPpart(weak_ref parent, const int number, const IMAPParser::body_type_mpart* mpart) +IMAPpart::IMAPpart(ref 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 - (thisWeakRef().dynamicCast (), mpart->list()); } -IMAPpart::IMAPpart(weak_ref parent, const int number, const IMAPParser::body_type_1part* part) +IMAPpart::IMAPpart(ref 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 thisRef(); /** Return a reference to this object (const version). + * \warning NEVER CALL THIS FROM A CONSTRUCTOR! * * @return reference to self */ ref thisRef() const; /** Return a weak reference to this object. + * \warning NEVER CALL THIS FROM A CONSTRUCTOR! * * @return weak reference to self */ weak_ref thisWeakRef(); /** Return a weak reference to this object (const version). + * \warning NEVER CALL THIS FROM A CONSTRUCTOR! * * @return weak reference to self */