From 9998d5e9c996ec048978168a608e465f9466628a Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Sat, 23 Aug 2008 15:20:50 +0000 Subject: [PATCH] Merged revisions 851216 via svnmerge from svn+ssh://tmcguire@svn.kde.org/home/kde/branches/KDE/4.1/kdepim ........ r851216 | tmcguire | 2008-08-23 12:12:29 +0200 (Sat, 23 Aug 2008) | 12 lines Backport r847987 by tmcguire from trunk to the 4.1 branch: Don't duplicate attachment handling code in the mime part tree. This fixes crashes when viewing loaded-on-demand attachments via the mime tree, since it would not set mAtmUpdate correctly, which prevents re-creating the part tree when the part is retrived. Re-creating the part-tree would make the pointers inside the map of the load parts command invalid and therefore trigger a crash. CCBUG: 136145 ........ svn path=/branches/kdepim/enterprise4/kdepim/; revision=851355 --- kmmimeparttree.cpp | 10 ++-------- kmreaderwin.cpp | 12 +++++++++--- kmreaderwin.h | 20 ++++++++++++++++++-- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/kmmimeparttree.cpp b/kmmimeparttree.cpp index 0a5ad906d..bb318038c 100644 --- a/kmmimeparttree.cpp +++ b/kmmimeparttree.cpp @@ -298,16 +298,10 @@ void KMMimePartTree::startHandleAttachmentCommand( int action ) return; partNode *node = static_cast( selected.first() )->node(); - QString name = mReaderWin->tempFileUrlFromPartNode( node ).path(); - KMHandleAttachmentCommand *command = new KMHandleAttachmentCommand( - node, mReaderWin->message(), node->nodeId(), name, - KMHandleAttachmentCommand::AttachmentAction( action ), - KService::Ptr(), this ); - connect( command, SIGNAL( showAttachment( int, const QString& ) ), - mReaderWin, SLOT( slotAtmView( int, const QString& ) ) ); - command->start(); + mReaderWin->prepareHandleAttachment( node->nodeId(), name ); + mReaderWin->slotHandleAttachment( action ); } void KMMimePartTree::slotCopy() diff --git a/kmreaderwin.cpp b/kmreaderwin.cpp index 757c8692c..c14ee2141 100644 --- a/kmreaderwin.cpp +++ b/kmreaderwin.cpp @@ -1960,10 +1960,16 @@ void KMReaderWin::slotUrlPopup(const QString &aUrl, const QPoint& aPos) } //----------------------------------------------------------------------------- -void KMReaderWin::showAttachmentPopup( int id, const QString & name, const QPoint &p ) +void KMReaderWin::prepareHandleAttachment( int id, const QString& fileName ) { mAtmCurrent = id; - mAtmCurrentName = name; + mAtmCurrentName = fileName; +} + +//----------------------------------------------------------------------------- +void KMReaderWin::showAttachmentPopup( int id, const QString & name, const QPoint &p ) +{ + prepareHandleAttachment( id, name ); KMenu *menu = new KMenu(); QAction *action; @@ -2663,7 +2669,7 @@ void KMReaderWin::slotEditAttachment(partNode * node) command->start(); } -KMail::CSSHelper* KMReaderWin::cssHelper() +KMail::CSSHelper* KMReaderWin::cssHelper() const { return mCSSHelper; } diff --git a/kmreaderwin.h b/kmreaderwin.h index 129595efc..2bcff5340 100644 --- a/kmreaderwin.h +++ b/kmreaderwin.h @@ -282,6 +282,13 @@ public: emit popupMenu( *message(), url, p ); } + /** + * Sets the current attachment ID and the current attachment temporary filename + * to the given values. + * Call this so that slotHandleAttachment() knows which attachment to handle. + */ + void prepareHandleAttachment( int id, const QString& fileName ); + void showAttachmentPopup( int id, const QString & name, const QPoint & p ); /** Set the serial number of the message this reader window is currently @@ -308,6 +315,8 @@ public: /* show or hide the list that points to the attachments */ void setShowAttachmentQuicklist( bool showAttachmentQuicklist = true ) { mShowAttachmentQuicklist = showAttachmentQuicklist; } + KMail::CSSHelper* cssHelper() const; + signals: /** Emitted after parsing of a message to have it stored in unencrypted state in it's folder. */ @@ -386,7 +395,15 @@ public slots: void slotDeleteAttachment( partNode* node ); void slotEditAttachment( partNode* node ); - KMail::CSSHelper* cssHelper(); + + /** + * Does an action for the current attachment. + * The action is defined by the KMHandleAttachmentCommand::AttachmentAction + * enum. + * prepareHandleAttachment() needs to be called before calling this to set the + * correct attachment ID. + */ + void slotHandleAttachment( int action ); protected slots: void slotCycleHeaderStyles(); @@ -406,7 +423,6 @@ protected slots: /** Some attachment operations. */ void slotAtmView( int id, const QString& name ); void slotDelayedResize(); - void slotHandleAttachment( int ); /** Print message. Called on as a response of finished() signal of mPartHtmlWriter after rendering is finished.