talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 8880d1a9996875e5cb872509de1d47c22e0b9b04
parent 408a4be23469ffb9998c30c4e2282b4bd1541e08
Author: Colin Leroy <colin@colino.net>
Date:   Wed, 30 Apr 2014 22:48:13 +0200

Fix bug #2398, "Race when closing compose during drafting"
Thanks to Michael Schwendt for spotting the problem.

Diffstat:
Msrc/compose.c | 16++++++++++++++--
Msrc/compose.h | 1+
2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/compose.c b/src/compose.c @@ -11453,16 +11453,28 @@ gboolean compose_close(Compose *compose) { gint x, y; + cm_return_val_if_fail(compose, FALSE); + if (!g_mutex_trylock(compose->mutex)) { /* we have to wait for the (possibly deferred by auto-save) * drafting to be done, before destroying the compose under * it. */ debug_print("waiting for drafting to finish...\n"); compose_allow_user_actions(compose, FALSE); - g_timeout_add (500, (GSourceFunc) compose_close, compose); + if (compose->close_timeout_tag == 0) { + compose->close_timeout_tag = + g_timeout_add (500, (GSourceFunc) compose_close, + compose); + } return FALSE; } - cm_return_val_if_fail(compose, FALSE); + + if (compose->close_timeout_tag) { + /* let the close be done by the deferred callback */ + g_mutex_unlock(compose->mutex); + return FALSE; + } + gtkut_widget_get_uposition(compose->window, &x, &y); if (!compose->batch) { prefs_common.compose_x = x; diff --git a/src/compose.h b/src/compose.h @@ -235,6 +235,7 @@ struct _Compose gboolean automatic_break; GMutex *mutex; + gint close_timeout_tag; gchar *orig_charset; gint set_cursor_pos;