Revision: 7309
          http://mahogany.svn.sourceforge.net/mahogany/?rev=7309&view=rev
Author:   vadz
Date:     2007-08-04 07:11:29 -0700 (Sat, 04 Aug 2007)

Log Message:
-----------
use SendMessage_obj instead of raw SendMessage* to avoid memory leaks

Modified Paths:
--------------
    trunk/M/src/gui/wxComposeView.cpp

Modified: trunk/M/src/gui/wxComposeView.cpp
===================================================================
--- trunk/M/src/gui/wxComposeView.cpp   2007-07-30 01:31:52 UTC (rev 7308)
+++ trunk/M/src/gui/wxComposeView.cpp   2007-08-04 14:11:29 UTC (rev 7309)
@@ -3326,7 +3326,7 @@
       case WXMENU_COMPOSE_PREVIEW:
          if(m_editor->FinishWork())
          {
-            SendMessage *msg = BuildMessage();
+            SendMessage_obj msg(BuildMessage());
             if ( !msg )
             {
                wxLogError(_("Failed to create the message to preview."));
@@ -3334,8 +3334,6 @@
             else
             {
                msg->Preview();
-
-               delete msg;
             }
          }
          break;
@@ -4272,7 +4270,7 @@
    }
 
    // Create the message to be composed
-   SendMessage *msg = SendMessage::Create(m_Profile, proto, ::GetFrame(this));
+   SendMessage_obj msg(SendMessage::Create(m_Profile, proto, 
::GetFrame(this)));
    if ( !msg )
    {
       // can't do anything more
@@ -4543,7 +4541,8 @@
       msg->AddHeaderEntry(headerNames[nHeader], headerValues[nHeader]);
    }
 
-   return msg;
+   // the caller is responsible for deleting the object
+   return msg.Detach();
 }
 
 bool
@@ -4558,7 +4557,7 @@
                                          : _("Sending message..."));
    Disable();
 
-   SendMessage *msg = BuildMessage();
+   SendMessage_obj msg(BuildMessage());
    if ( !msg )
    {
       wxLogError(_("Failed to create the message to send."));
@@ -4574,7 +4573,7 @@
          (MModule_Calendar *) MModule::GetProvider(MMODULE_INTERFACE_CALENDAR);
       if(calmod)
       {
-         success = calmod->ScheduleMessage(msg);
+         success = calmod->ScheduleMessage(msg.Get());
          calmod->DecRef();
       }
       else
@@ -4594,8 +4593,6 @@
       success = msg->SendOrQueue(flags);
    }
 
-   delete msg;
-
    if ( success )
    {
       if ( READ_CONFIG(m_Profile, MP_AUTOCOLLECT_OUTGOING) )
@@ -4624,32 +4621,32 @@
       mApplication->UpdateOutboxStatus();
 
       // show the recipients of the message
-      String msg;
+      String s;
       if ( m_mode == Mode_News )
       {
-         msg.Printf(_("Message has been posted to %s"),
-                    GetRecipients(Recipient_Newsgroup).c_str());
+         s.Printf(_("Message has been posted to %s"),
+                  GetRecipients(Recipient_Newsgroup).c_str());
       }
       else // email message
       {
          // NB: don't show BCC as the message might be saved in the log file
-         msg.Printf(_("Message has been sent to %s"),
-                    GetRecipients(Recipient_To).c_str());
+         s.Printf(_("Message has been sent to %s"),
+                  GetRecipients(Recipient_To).c_str());
 
          String rcptCC = GetRecipients(Recipient_Cc);
          if ( !rcptCC.empty() )
          {
-            msg += String::Format(_(" (with courtesy copy sent to %s)"),
-                                  rcptCC.c_str());
+            s += String::Format(_(" (with courtesy copy sent to %s)"),
+                                rcptCC.c_str());
          }
          else // no CC
          {
-            msg += '.';
+            s += '.';
          }
       }
 
-      // avoid crashes if the msg has any stray '%'s
-      wxLogStatus(this, _T("%s"), msg.c_str());
+      // avoid crashes if the message has any stray '%'s
+      wxLogStatus(this, _T("%s"), s.c_str());
    }
    else // message not sent
    {
@@ -5002,7 +4999,7 @@
 
 SendMessage *wxComposeView::BuildDraftMessage(int flags) const
 {
-   SendMessage *msg = BuildMessage(flags);
+   SendMessage_obj msg(BuildMessage(flags));
    if ( !msg )
    {
       if ( flags & Interactive )
@@ -5039,7 +5036,7 @@
    // also save the Fcc header contents because it's not a "real" header
    msg->AddHeaderEntry(_T("FCC"), GetRecipients(Recipient_Fcc));
 
-   return msg;
+   return msg.Detach();
 }
 
 // from upgrade.cpp, this forward decl will disappear once we move it somewhere


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to