From 70e1bee969ed22d886a1179d2776171469d04779 Mon Sep 17 00:00:00 2001 From: Bo Thorsen Date: Tue, 28 Sep 2004 08:42:08 +0000 Subject: [PATCH] From the branch: Plugging two memleaks - the message was never deleted, and the composewin was not deleted when using automatic sending svn path=/trunk/kdepim/; revision=349931 --- kmcomposewin.cpp | 8 ++++++++ kmcomposewin.h | 6 ++++++ kmkernel.cpp | 12 ++++++------ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/kmcomposewin.cpp b/kmcomposewin.cpp index b3aa96621..2e357e508 100644 --- a/kmcomposewin.cpp +++ b/kmcomposewin.cpp @@ -364,6 +364,14 @@ KMComposeWin::~KMComposeWin() std::for_each( mComposedMessages.begin(), mComposedMessages.end(), DeleteObject ); } +void KMComposeWin::setAutoDeleteWindow( bool f ) +{ + if ( f ) + setWFlags( getWFlags() | WDestructiveClose ); + else + setWFlags( getWFlags() & ~WDestructiveClose ); +} + //----------------------------------------------------------------------------- void KMComposeWin::send(int how) { diff --git a/kmcomposewin.h b/kmcomposewin.h index 4ad93e4ea..49db5f6be 100644 --- a/kmcomposewin.h +++ b/kmcomposewin.h @@ -314,6 +314,12 @@ public: */ inline void setAutoDelete(bool f) { mAutoDeleteMsg = f; } + /** + * If this flag is set, the compose window will delete itself after + * the window has been closed. + */ + void setAutoDeleteWindow( bool f ); + /** * If this folder is set, the original message is inserted back after * cancelling diff --git a/kmkernel.cpp b/kmkernel.cpp index 2e65b824d..3c20f6536 100644 --- a/kmkernel.cpp +++ b/kmkernel.cpp @@ -426,7 +426,7 @@ int KMKernel::openComposer (const QString &to, const QString &cc, if ( !to.isEmpty() ) msg->setTo(to); if ( !body.isEmpty() ) msg->setBody(body.utf8()); - bool iCalHack = false; + bool iCalAutoSend = false; KConfigGroup options( config(), "Groupware" ); if ( !attachData.isEmpty() ) { if ( attachName == "cal.ics" && attachType == "text" && @@ -440,7 +440,7 @@ int KMKernel::openComposer (const QString &to, const QString &cc, arg( attachParamValue ) ); // Don't show the composer window, if the automatic sending is checked - iCalHack = options.readBoolEntry( "AutomaticSending", true ); + iCalAutoSend = options.readBoolEntry( "AutomaticSending", true ); } else { // Just do what we're told to do msgPart = new KMMessagePart; @@ -460,14 +460,15 @@ int KMKernel::openComposer (const QString &to, const QString &cc, } KMComposeWin *cWin = new KMComposeWin( msg ); - if( iCalHack ) + cWin->setAutoDelete( true ); + if( iCalAutoSend ) cWin->slotWordWrapToggled( false ); else cWin->setCharset( "", true ); if ( msgPart ) cWin->addAttach(msgPart); - if ( hidden == 0 && !iCalHack ) { + if ( hidden == 0 && !iCalAutoSend ) { cWin->show(); // Activate window - doing this instead of KWin::activateWindow(cWin->winId()); // so that it also works when called from KMailApplication::newInstance() @@ -475,8 +476,7 @@ int KMKernel::openComposer (const QString &to, const QString &cc, KStartupInfo::setNewStartupId( cWin, kapp->startupId() ); #endif } else { - // TODO: Delete the window - kdDebug(5006) << "Hidden send now window\n"; + cWin->setAutoDeleteWindow( true ); cWin->slotSendNow(); }