|
Hello Not Thank you for your work, I have been to the gnome bugzilla and seen #122356 as you told me, it is just as we have discussed. Thank you. Following your advice, I studied the related parts of the code. Now I still think we should force a "response" signal to the dialog, but not simply widget_destroy it. Because this dialog (the property dialog of attachment) is not created with nothing else, in fact the dialog is a member of the struct Dialog_Data. Each time we popped up a dialog, we create a Dialog_Data to manage it, and it is also in charge of some related handler. In the ideal case, we click the ok or cancel or just close the dialog, that will invoke the close_cb or ok_cb. What these funcion do is to unref the attachment, destroy the property dialog as one of Dialog_Data's MEMBER, and free itself(Dialog_Data) finally. Another case is that we close this compose window directly. If there is a opened property dialog when we close the compose window, the function can be invoked also because we have gtk_signal_connect_while_alive (parent, "destroy", close_cb....., dialog). Here parent is the compose window, close_cb is the handler, dialog is the property dialog, when the dialog is alive, the compose window's destroy signal can cause the close_cb function activity. Then we come to the focus. When we remove an attachment with its property dialog opened, if we just call widget_destroy, the dialog can be destroyed but the Dialog_Data is missed by us. And because we use this form of connect_while_alive, if we close this compose window, this Dialog_Data will not be freed either. Thus we leaked it. So I think we can force a "response" signal to the dialog, and in its signal handler "response_cb()" at line 382, it's the Dialog_Data's turn to destroy its member(the dialog) and free itself at last. Are you with me? I have attached another patch, please review it if. Best Regards Charles Zhang Not Zed wrote: I've followed this up further. - gnome bugzilla bug #122356, including a patch to fix it - you can not do a g_list_reverse on the list returned by get_selection! It is static/internal data which must remain in the correct order. You will have to copy the list. - so having said all that: - put the duplicate entry checking stuff in the original first-loop, with a comment referencing the above bug - add a destroy call in remove_attachment if the editor is up leave everything else as is. On Mon, 2003-09-15 at 11:23 -0500, Not Zed wrote: |
Index: composer/e-msg-composer-attachment-bar.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer-attachment-bar.c,v
retrieving revision 1.67.4.4
diff -u -p -r1.67.4.4 e-msg-composer-attachment-bar.c
--- composer/e-msg-composer-attachment-bar.c 30 Jul 2003 12:59:06 -0000 1.67.4.4
+++ composer/e-msg-composer-attachment-bar.c 16 Sep 2003 14:17:10 -0000
@@ -192,9 +192,16 @@ static void
remove_attachment (EMsgComposerAttachmentBar *bar,
EMsgComposerAttachment *attachment)
{
+ g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar));
+ g_return_if_fail (g_list_find (bar->priv->attachments, attachment) != NULL);
+
bar->priv->attachments = g_list_remove (bar->priv->attachments,
attachment);
bar->priv->num_attachments--;
+ if (attachment->editor_gui != NULL) {
+ GtkWidget *window = glade_xml_get_widget (attachment->editor_gui, "dialog");
+ g_signal_emit_by_name (window, "response", GTK_RESPONSE_CLOSE);
+ }
g_object_unref(attachment);
@@ -356,8 +363,15 @@ remove_selected (EMsgComposerAttachmentB
p = gnome_icon_list_get_selection (icon_list);
for ( ; p != NULL; p = p->next) {
num = GPOINTER_TO_INT (p->data);
- attachment = E_MSG_COMPOSER_ATTACHMENT (g_list_nth (bar->priv->attachments, num)->data);
- attachment_list = g_list_prepend (attachment_list, attachment);
+ attachment = E_MSG_COMPOSER_ATTACHMENT (g_list_nth_data (bar->priv->attachments, num));
+
+ /* We need to check if there are duplicated index in the return value of
+ gnome_icon_list_get_selection() because of gnome bugzilla bug #122356.
+ FIXME in the future. */
+
+ if (g_list_find (attachment_list, attachment) == NULL) {
+ attachment_list = g_list_prepend (attachment_list, attachment);
+ }
}
for (p = attachment_list; p != NULL; p = p->next)
Index: composer/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
retrieving revision 1.544.2.13
diff -u -p -r1.544.2.13 ChangeLog
--- composer/ChangeLog 29 Aug 2003 05:57:25 -0000 1.544.2.13
+++ composer/ChangeLog 16 Sep 2003 14:17:13 -0000
@@ -10,6 +10,13 @@
and composer icon name to get the path of composer icon.
[#47781]
+2003-09-13 Charles Zhang <charles zhang sun com>
+
+ * e-msg-composer-attachment.c (remove_attachment): add assertion
+ * e-msg-composer-attachment.c (remove_selected): fix a re-remove-
+ attachment bug; close opened edit-dialog while removng attachment.
+ [#48466]
+
2003-08-19 Jeffrey Stedfast <fejj ximian com>
* Original patch from David Woodhouse, but modified a bit by me.