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

List:       kmail-devel
Subject:    Bug#30475: crash when typing f while kmail starts
From:       Ingo =?iso-8859-1?q?Kl=F6cker?= <ingo.kloecker () epost ! de>
Date:       2001-08-19 15:24:36
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sonntag, 19. August 2001 15:24, Don Sanders wrote:
> On Sunday 19 August 2001 11:54, Ingo Klöcker wrote:
> > On Sonntag, 19. August 2001 00:29, Ingo Klöcker wrote:
> > > No. But I found the cause of the crash. KMail crashes
> > > in the following line
> > >
> > >   win->setCharset(msg->codec()->name(), TRUE);
> > >
> > > near the end of KMHeaders::forwardMsg(). The reason for
> > > the crash is msg->codec() == NULL.
> > > I guess the codec of the current message still hasn't
> > > been initialized when the forward action is processed.
> > >
> > > The attached simple patch will prevent this crash.
> > >
> > > This fix will have to be applied to all message related
> > > actions, e.g. KMHeaders::redirectMsg(),
> > > KMHeaders::replyToMsg(), etc., because they all contain
> > > the above line. (I haven't tried if they all crash
> > > KMail.)
> >
> > KMail does indeed also crash if you hold down 'r' or 'e',
> > etc., while KMail starts.
> >
> > The attached patch fixes this problem in all cases.
>
> And you think it's best just to return? Rather than to say
>
> +if (msg->codec())
>    win->setCharset(msg->codec()->name(), TRUE);

Well, the charset has to be set to some reasonable value. So only 
setting the charset if msg->codec() != 0 isn't a good solution. A 
slightly better solution would be

 +if (msg->codec())
    win->setCharset(msg->codec()->name(), TRUE);
 +else
 +  win->setCharset("Unicode", TRUE);

But please keep in mind that this problem only occurs if the user holds 
one of the message related keys pressed while KMail is started.

> I wonder what the root of the problem is, well if you have
> a fix please commit.

The root of the problem seems to be that msg->setCodec(...) is only 
called in KMReaderWin::setMsg() and in KMReaderWin::parseMsg(). This 
means that codec is NULL before any of these two functions is executed. 
And this seems to be the case right after the start of KMail because 
the first actions (e.g. the forward action) are already processed 
before the message is displayed in the reader pane.

My fix only cures the symptoms, i.e. the processing of the message 
related actions will be aborted until the message is shown correctly in 
the reader pane (resp. until the codec is set correctly).

The correct fix would be to either move the setting of the codec from 
KMReaderWin to KMMessage or to copy the code which chooses the correct 
codec from KMReaderWin::parseMsg() to KMHeaders so that the codec can 
be set to a reasonable value if it's still unset. BTW, this will be 
important if we ever make it possible to turn of the reader pane 
because then the codec won't be set by the corresponding code in 
KMReaderWin.

The following is the code which is responsible for the automatic 
selection of the codec (cf. KMReaderWin::parseMsg()):

    mCodec = 0;
    QCString encoding;
    if (type.find("text/") != -1)
      encoding = mMsg->charset();
    else if (type.find("multipart/") != -1) {
      if (mMsg->numBodyParts() > 0) {
        KMMessagePart msgPart;
        mMsg->bodyPart(0, &msgPart);
        encoding = msgPart.charset();
      }
    }
    if (encoding.isEmpty())
      encoding = "iso8859-1";
    mCodec = KMMsgBase::codecForName(encoding);

IMHO this code could be moved to the initialization of a KMMessage 
object, i.e. maybe to KMMessage::KMMessage(). I'm not completely sure 
if this is the right place.

What do you think about this?

Regards,
Ingo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE7f9o4GnR+RTDgudgRAiatAJ9YKqWZru64+vGC8XA0S1FhoxztwwCfRAz2
d6Q3LQg0ERsiz4frYA3M3m0=
=DROC
-----END PGP SIGNATURE-----
_______________________________________________
Kmail Developers mailing list
Kmail@mail.kde.org
http://mail.kde.org/mailman/listinfo/kmail

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

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