Bug 92412

Summary: If PGP/MIME encrypted messages are BCC'ed then except for one message all messages are empty
Product: [Applications] kmail Reporter: Ingo Klöcker <kloecker>
Component: encryptionAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: major CC: david.guembel
Priority: NOR    
Version: 1.7   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Ingo Klöcker 2004-10-30 22:06:23 UTC
Version:           1.7.50 (using KDE 3.3.0, compiled sources)
Compiler:          gcc version 3.3.3 (SuSE Linux)
OS:                Linux (i686) release 2.6.5-7.108-default

Send an PGP/MIME encrypted message to someone and BCC yourself. Two messages will be created (which is intended behavior). One message contains the encrypted message text, but the second message only contains an encrypted empty message part.
Comment 1 Ingo Klöcker 2004-10-30 22:07:31 UTC
This problem is also present in KDE 3.3 and KDE 3.3.1.
Comment 2 Ingo Klöcker 2004-10-30 22:21:43 UTC
CVS commit by kloecker: 

Fix PGP/MIME encrypting messages which are BCC'ed. The problem was that KMMessagePart contains a QByteArray which is explicitely shared. Therefore simply copying a KMMessagePart with the copy c'tor for getting a temporary copy isn't possible. Implementing and using a duplicate method fixes the problem.
BUG: 92412


  M +9 -0      kmmsgpart.cpp   1.113
  M +4 -0      kmmsgpart.h   1.42
  M +2 -1      messagecomposer.cpp   1.36


--- kdepim/kmail/kmmsgpart.h  #1.41:1.42
@@ -23,4 +23,8 @@ public:
   void clear();
 
+  /** Obtains an independant copy (i.e. without explicitely shared data) of the
+      data contained in msgPart. Returns a reference to this message part. */
+  KMMessagePart & duplicate( const KMMessagePart & msgPart );
+
   /** Get or set the message body */
   QCString body(void) const;

--- kdepim/kmail/kmmsgpart.cpp  #1.112:1.113
@@ -81,4 +81,13 @@ void KMMessagePart::clear()
 
 //-----------------------------------------------------------------------------
+KMMessagePart & KMMessagePart::duplicate( const KMMessagePart & msgPart )
+{
+  // copy the data of msgPart
+  *this = msgPart;
+  // detach the explicitely shared QByteArray
+  mBody.detach();
+}
+
+//-----------------------------------------------------------------------------
 int KMMessagePart::decodedSize(void) const
 {

--- kdepim/kmail/messagecomposer.cpp  #1.35:1.36
@@ -960,5 +960,6 @@ public:
 
   void execute() {
-    KMMessagePart tmpNewBodyPart = *mNewBodyPart;
+    KMMessagePart tmpNewBodyPart;
+    tmpNewBodyPart.duplicate( *mNewBodyPart );
 
     // TODO: Async call


Comment 3 Till Adam 2004-12-14 09:06:22 UTC
*** Bug 91697 has been marked as a duplicate of this bug. ***