From f3c501237152a9a5992232b4849f7d6b1c7843d2 Mon Sep 17 00:00:00 2001 From: Till Adam Date: Wed, 28 Jul 2004 09:33:56 +0000 Subject: [PATCH] Make sure the (local) sent mail folder, where a mail is put as a fallback, before being moved to an imap sent mail folder, is kept open, otherwise the KMMsgBase pointers passed to the command become invalid. Introduce KMCommand::keepFolderOpen( KMFolder* ) which opens a folder and adds it to the list of folders to be closed by the dtor. svn path=/trunk/kdepim/; revision=333462 --- kmcommands.cpp | 6 ++++++ kmcommands.h | 6 ++++++ kmsender.cpp | 1 + 3 files changed, 13 insertions(+) diff --git a/kmcommands.cpp b/kmcommands.cpp index 2dca0eded..42f68fd82 100644 --- a/kmcommands.cpp +++ b/kmcommands.cpp @@ -368,6 +368,12 @@ void KMCommand::slotTransferCancelled() emit messagesTransfered( Canceled ); } +void KMCommand::keepFolderOpen( KMFolder *folder ) +{ + folder->open(); + mFolders.append( folder ); +} + KMMailtoComposeCommand::KMMailtoComposeCommand( const KURL &url, KMMessage *msg ) :mUrl( url ), mMessage( msg ) diff --git a/kmcommands.h b/kmcommands.h index 50e806e76..77f61be89 100644 --- a/kmcommands.h +++ b/kmcommands.h @@ -47,6 +47,12 @@ public: KMCommand( QWidget *parent, KMMessage *message ); virtual ~KMCommand(); + /** These folders will be closed by the dtor, handy, if you need to keep + a folder open during the lifetime of the command, but don't want to + care about closing it again. + */ + void keepFolderOpen( KMFolder *folder ); + /** Returns the result of the command. Only call this method from the slot connected to completed(). */ diff --git a/kmsender.cpp b/kmsender.cpp index e0dc81664..6de1658ed 100644 --- a/kmsender.cpp +++ b/kmsender.cpp @@ -348,6 +348,7 @@ void KMSender::doSendMsg() if (imapSentFolder) { // Does proper folder refcounting and message locking KMCommand *command = new KMMoveCommand( imapSentFolder, mCurrentMsg ); + command->keepFolderOpen( sentFolder ); // will open it, and close it once done command->start(); } default: