#23 Fix crash in on_check_mail_menu_activate

closed-accepted
Daler
None
9
2002-02-26
2002-02-12
Steven Augart
No

Brief summary: Modifies on_check_mail_menu_activate()
in callbacks.cpp:

This describes modifications to the function
on_check_mail_menu_activate(). It fixes a crash that
happens if we
have already failed to read a folder list from the
server.

*Problems corrected:

**We never checked whether the_server->get_Folder()
succeeded.
(If we fail to read the folder list from the server,
then that
call won't succeed, and havoc will result -- I should
know; this
happened to me!).

**gAlthea.get_Current_Server() was being called after
we'd
already initialized the variable the_server with its
contents. This in turn deceived the programmer into
writing some redundant code to handle the pointer
Ťthe_serverť being NULL. This redundant code was never
executed, since that check had already been performed.

**We called the_server->get_Folder() before we had a
reservation for
the server.

*Enhancement
When there is no server available (because none has
been set up yet),
on_check_mail_menu_activate will now give the better
error message:
"Go to Althea ==> Setup... and define a server."
instead of the confusing:
"Select a server first."

*Problems not corrected (yet?):
**The server reservation (6 lines) is code repeated in
a number of places;
should be consolidated into a method of the Server
class (something
like reserve_server_blocking().

**There's a synchronization problem with the server
reservation code.
Only way to fix this is to go over to using a proper
Posix 1003.1c mutex.

**Other places need checks for whether a current server
exists.
I made on_expunge_menu_activate() dump core.

A couple of other functions do use assertions to
confirm that there's
a current server. A step in the right direction, but
obviously a user
action should never trigger an assertion.

It would be good to have this code modularized and put
it there. The
right thing to do is have an
Althea::get_current_server_or_gripe()
method.

*Future Enhancement:
**When <Print> is clicked, check for whether there's a
current message
before popping up the dialogue box, not after.

Discussion

  • Steven Augart
    Steven Augart
    2002-02-12

    • priority: 5 --> 9
     
  • Daler
    Daler
    2002-02-26

    Logged In: YES
    user_id=99089

    The althea developers have decided to include your patch in the
    main source. Usually, your patch will be uploaded to the CVS
    source first and included in the next release of althea. Thanks
    for your contribution and keep submitting!

     
  • Daler
    Daler
    2002-02-26

    • assigned_to: nobody --> mulvihiw
    • status: open --> closed-accepted