Rework close and remove hacks for bad events
* src/mail.cpp (Mail::close): Make it static to handle the case were close causes a mail deletion. (Mail::close_inspector): Make it static. (Mail::close_all_mails): Close inspector first. Handle map changes and object deletion. (Mail::~Mail): Don't delete event sink. (Mail::get_close_triggered, Mail::set_close_triggered): New. * src/mailitem-events.h (EVENT_SINK_INVOKE): Remove uneccessary Close hacks. Fix fallthrough from Open to before read. Fix fallthrough from Close to unload. Check if a close was triggered by us. (request_close, request_decrypt): Remvoed. * src/windowmessages.cpp, src/windowmessages.h (REQUEST_DECRYPT) (REQUEST_CLOSE): Removed.
This fixes various inconsistentcies in the Close handling, especially
if the Object calling the close was deleted during the call. Also
closing the inspectors before closing the mail fixes a crash that
could be triggered if more then one mail was open when closing.
The proper closing now also prevents the necessity for decrypt again.
The Open to BeforeRead fallthrough should not be a big issue,
still a problem. And the close to unload fallthrough with my
long comments explaining it,.. well *facepalm*..
- GnuPG-Bug-Id: T2855