From f266760a46d4e27fecf7403cc3b687feb0ef8dd1 Mon Sep 17 00:00:00 2001 From: Ismail Onur Filiz Date: Tue, 14 Mar 2006 20:17:40 +0000 Subject: [PATCH] Fixes the following crash, by adding check for null-pointers: A message part that is not an email by itself is "view"ed. When reply or forward actions are triggered, KMail crashes. It also hides the main toolbar and menu for non-message viewers. BUG: 123316 GUI: Remove menu and toolbar for e-mail parts that are not e-mails themselves. svn path=/branches/KDE/3.5/kdepim/; revision=518656 --- kmcommands.cpp | 3 ++- kmreadermainwin.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/kmcommands.cpp b/kmcommands.cpp index c2a9e1aeb..0c1c605eb 100644 --- a/kmcommands.cpp +++ b/kmcommands.cpp @@ -170,7 +170,8 @@ KMCommand::KMCommand( QWidget *parent, KMMessage *msg ) : mProgressDialog( 0 ), mResult( Undefined ), mDeletesItself( false ), mEmitsCompletedItself( false ), mParent( parent ) { - mMsgList.append( &msg->toMsgBase() ); + if (msg) + mMsgList.append( &msg->toMsgBase() ); } KMCommand::~KMCommand() diff --git a/kmreadermainwin.cpp b/kmreadermainwin.cpp index aab2fa209..4b26166f9 100644 --- a/kmreadermainwin.cpp +++ b/kmreadermainwin.cpp @@ -89,6 +89,10 @@ void KMReaderMainWin::initKMReaderMainWin() { setupAccel(); setupGUI( ToolBar | Keys | StatusBar | Create, "kmreadermainwin.rc" ); applyMainWindowSettings( KMKernel::config(), "Separate Reader Window" ); + if ( ! mReaderWin->message() ) { + menuBar()->hide(); + toolBar( "mainToolBar" )->hide(); + } connect( kmkernel, SIGNAL( configChanged() ), this, SLOT( slotConfigChanged() ) ); @@ -113,6 +117,7 @@ void KMReaderMainWin::showMsg( const QString & encoding, KMMessage *msg ) mReaderWin->setMsg( msg, true ); setCaption( msg->subject() ); mMsg = msg; + menuBar()->show(); toolBar( "mainToolBar" )->show(); } @@ -162,7 +167,7 @@ void KMReaderMainWin::slotReplyListToMsg() void KMReaderMainWin::slotForwardMsg() { KMCommand *command = 0; - if ( mReaderWin->message()->parent() ) { + if ( mReaderWin->message() && mReaderWin->message()->parent() ) { command = new KMForwardCommand( this, mReaderWin->message(), mReaderWin->message()->parent()->identity() ); } else { @@ -175,7 +180,7 @@ void KMReaderMainWin::slotForwardMsg() void KMReaderMainWin::slotForwardAttachedMsg() { KMCommand *command = 0; - if ( mReaderWin->message()->parent() ) { + if ( mReaderWin->message() && mReaderWin->message()->parent() ) { command = new KMForwardAttachedCommand( this, mReaderWin->message(), mReaderWin->message()->parent()->identity() ); } else {