[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    Re: Serial number-related trouble, again
From:       David Faure <dfaure () klaralvdalens-datakonsult ! se>
Date:       2005-05-27 9:11:57
Message-ID: 200505271111.59019.dfaure () klaralvdalens-datakonsult ! se
[Download RAW message or body]

On Friday 27 May 2005 03:25, Don Sanders wrote:
> You can't have two different messages (an original and a copy) with 
> different serial numbers. A serial number relates to a unique message 
> in a particular folder at a particular offset within the index.

OK, this helps a lot. Then the bug is simply this line:

void KMMainWidget::slotMsgActivated(KMMessage *msg)
{
   [...]
  KMReaderMainWin *win = new KMReaderMainWin( mFolderHtmlPref );
  KMMessage *newMessage = new KMMessage(*msg);
  newMessage->setParent( msg->parent() );
  newMessage->setMsgSerNum( msg->getMsgSerNum() ); <<<<<<<<<<<<<<<<
  newMessage->setReadyToShow( true );
  win->showMsg( mCodec, newMessage );
  win->show();
}

That line was added as part of the fixes for http://bugs.kde.org/show_bug.cgi?id=71385

If I remove the setMsgSerNum call, then "Save As" from the separate reader window
fails indeed. This is because of:
void KMSaveMsgCommand::slotSaveDataReq()
{
   [...]
   kmkernel->msgDict()->getLocation( mMsgList[mMsgListIndex], &p, &idx );
   assert( p );
   [...]
}
(it obviously can't look up the message by serial number since it has none)

So...... why do we make a copy of the message in the first place? I guess
"because it might be deleted", but that's wrong thinking, since KMReaderWin
only remembers the serial number of the message, not the KMMessage pointer.

Things work OK again if I remove the KMMessage copying in KMMainWidget::slotMsgActivated,
and if I disable auto-deletion-of-the-message in this case (new ctor argument
so that it doesn't affect other uses of KMReaderWin, there's no serial number when
viewing an attached mail, so autodeletion is needed).

However a new bug appears: after saving a message (from the separate reader window),
the header list goes blank !?!?!?

-- 
David Faure -- faure@kde.org, dfaure@klaralvdalens-datakonsult.se
Qt/KDE/KOffice developer
Klarälvdalens Datakonsult AB, Platform-independent software solutions

["fix.diff" (text/x-diff)]

Index: kmreadermainwin.cpp
===================================================================
--- kmreadermainwin.cpp	(revision 415305)
+++ kmreadermainwin.cpp	(working copy)
@@ -29,13 +29,13 @@
 #include "kmreadermainwin.h"
 #include "kmreadermainwin.moc"
 
-KMReaderMainWin::KMReaderMainWin( bool htmlOverride, char *name )
+KMReaderMainWin::KMReaderMainWin( bool htmlOverride, bool autoDeleteMessage, char *name )
   : KMail::SecondaryWindow( name ), mMsg( 0 )
 {
   KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
   mReaderWin = new KMReaderWin( this, this, actionCollection() );
   //mReaderWin->setShowCompleteMessage( true );
-  mReaderWin->setAutoDelete( true );
+  mReaderWin->setAutoDelete( autoDeleteMessage );
   mReaderWin->setHtmlOverride( htmlOverride );
   setCentralWidget( mReaderWin );
   setupAccel();
@@ -45,19 +45,6 @@
 }
 
 
-KMReaderMainWin::KMReaderMainWin( char *name )
-  : KMail::SecondaryWindow( name ), mMsg( 0 )
-{
-  mReaderWin = new KMReaderWin( this, this, actionCollection() );
-  mReaderWin->setAutoDelete( true );
-  setCentralWidget( mReaderWin );
-  setupAccel();
-
-  connect( kmkernel, SIGNAL( configChanged() ),
-           this, SLOT( slotConfigChanged() ) );
-}
-
-
 KMReaderMainWin::KMReaderMainWin(KMMessagePart* aMsgPart,
     bool aHTML, const QString& aFileName, const QString& pname,
     const QTextCodec *codec, char *name )
Index: kmmainwidget.cpp
===================================================================
--- kmmainwidget.cpp	(revision 415305)
+++ kmmainwidget.cpp	(working copy)
@@ -2004,12 +2004,8 @@
   }
 
   assert( msg != 0 );
-  KMReaderMainWin *win = new KMReaderMainWin( mFolderHtmlPref );
-  KMMessage *newMessage = new KMMessage(*msg);
-  newMessage->setParent( msg->parent() );
-  newMessage->setMsgSerNum( msg->getMsgSerNum() );
-  newMessage->setReadyToShow( true );
-  win->showMsg( mCodec, newMessage );
+  KMReaderMainWin *win = new KMReaderMainWin( mFolderHtmlPref, false /* don't autodelete */ );
+  win->showMsg( mCodec, msg );
   win->show();
 }
 
Index: kmreadermainwin.h
===================================================================
--- kmreadermainwin.h	(revision 415305)
+++ kmreadermainwin.h	(working copy)
@@ -21,8 +21,7 @@
   Q_OBJECT
 
 public:
-  KMReaderMainWin( bool htmlOverride, char *name = 0 );
-  KMReaderMainWin( char *name = 0 );
+  KMReaderMainWin( bool htmlOverride = false, bool autoDeleteMessage = true, char *name = 0 );
   KMReaderMainWin(KMMessagePart* aMsgPart,
     bool aHTML, const QString& aFileName, const QString& pname,
     const QTextCodec *codec, char *name = 0 );


_______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic