[prev in list] [next in list] [prev in thread] [next in thread]
List: kmail-devel
Subject: Re: Memory usage (Re: QCString construction)
From: Ingo =?iso-8859-15?q?Kl=F6cker?= <kloecker () kde ! org>
Date: 2007-02-16 20:46:51
Message-ID: 200702162147.05991 () erwin ! ingo-kloecker ! de
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
On Friday 16 February 2007 00:26, David Faure wrote:
> On Thursday 15 February 2007, Ingo Klöcker wrote:
> > + KMMessage msg;
> > + delete msg.mMsg;
> > + msg.mMsg = new DwMessage( *mMsg );
> >
> > I'd be more comfortable if there was a KMMessage::fromDwMessage(
> > const DwMessage &dwMsg ) doing the last two lines so that the above
> > would simply become
> > + KMMessage msg;
> > + msg.fromDwMessage( *mMsg );
>
> Actually, we could even save the new/delete (and the new method), by
> simply doing
> KMMessage msg( new DwMessage( this->mMsg ) );
> What do you think?
Yeah. Looks good. Now the only remaining issue is that
KMMessage::KMMessage(DwMessage* aMsg)
differs slightly from
KMMessage::KMMessage(KMFolder* parent) and the other two c'tors. In
KMMessage::init() a few more variables are initialized (mComplete,
mReadyToShow, mStatus) and moreover mNeedsAssembly is set to false
while in KMMessage::KMMessage(DwMessage* aMsg) it is set to true.
To fix this difference we should use init() also in
KMMessage::KMMessage(DwMessage* aMsg). I suggest the attached patch.
Regards,
Ingo
["kmmessage-2007-02-16.diff" (text/x-diff)]
Index: kmmessage.h
===================================================================
--- kmmessage.h (revision 609448)
+++ kmmessage.h (working copy)
@@ -845,7 +845,7 @@
private:
/** Initialization shared by the ctors. */
- void init();
+ void init( DwMessage* aMsg = 0 );
/** Assign the values of @param other to this message. Used in the copy c'tor. */
void assign( const KMMessage& other );
Index: kmmessage.cpp
===================================================================
--- kmmessage.cpp (revision 609448)
+++ kmmessage.cpp (working copy)
@@ -86,21 +86,11 @@
//-----------------------------------------------------------------------------
KMMessage::KMMessage(DwMessage* aMsg)
- : KMMsgBase(),
- mMsg(aMsg),
- mNeedsAssembly(true),
- mDecodeHTML(false),
- mOverrideCodec(0),
- mFolderOffset( 0 ),
- mMsgSize(0),
- mMsgLength( 0 ),
- mDate( 0 ),
- mEncryptionState( KMMsgEncryptionStateUnknown ),
- mSignatureState( KMMsgSignatureStateUnknown ),
- mMDNSentState( KMMsgMDNStateUnknown ),
- mUnencryptedMsg(0),
- mLastUpdated( 0 )
+ : KMMsgBase()
{
+ init( aMsg );
+ // aMsg might need assembly
+ mNeedsAssembly = true;
}
//-----------------------------------------------------------------------------
@@ -137,10 +127,14 @@
assign( other );
}
-void KMMessage::init()
+void KMMessage::init( DwMessage* aMsg )
{
mNeedsAssembly = false;
- mMsg = new DwMessage;
+ if ( aMsg ) {
+ mMsg = aMsg;
+ } else {
+ mMsg = new DwMessage;
+ }
mOverrideCodec = 0;
mDecodeHTML = false;
mComplete = true;
[Attachment #8 (application/pgp-signature)]
_______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic