[evolution-patches] patch for bug 48466
- From: Charles Zhang <Charles Zhang Sun Com>
- To: evolution-patches <evolution-patches lists ximian com>
- Subject: [evolution-patches] patch for bug 48466
- Date: Sun, 14 Sep 2003 15:49:57 +0800
Hello, all.
In this patch, I fix bug 48466.
It's about the attatchment-bar in the composer.
I've modified most of the code of function "remove_selected" in
the file "e-msg-composer-attatchment-bar.c" under dir "composer",
because it is less efficient and dangerous. Following the origin code,
attatchment will be removed more than one times.
Please review it.
Best Regards.
Charles
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 14 Sep 2003 07:28:51 -0000
@@ -192,10 +192,12 @@ static void
remove_attachment (EMsgComposerAttachmentBar *bar,
EMsgComposerAttachment *attachment)
{
+ g_return_if_fail (bar->priv->num_attachments > 0);
+
bar->priv->attachments = g_list_remove (bar->priv->attachments,
attachment);
bar->priv->num_attachments--;
-
+
g_object_unref(attachment);
g_signal_emit (bar, signals[CHANGED], 0);
@@ -341,30 +343,26 @@ update (EMsgComposerAttachmentBar *bar)
static void
remove_selected (EMsgComposerAttachmentBar *bar)
{
- GnomeIconList *icon_list;
EMsgComposerAttachment *attachment;
- GList *attachment_list, *p;
- int num;
-
- icon_list = GNOME_ICON_LIST (bar);
-
- /* Weee! I am especially proud of this piece of cheesy code: it is
- truly awful. But unless one attaches a huge number of files, it
- will not be as greedy as intended. FIXME of course. */
-
- attachment_list = NULL;
- p = gnome_icon_list_get_selection (icon_list);
+ GList *p;
+ gint num = -1;
+
+ p = gnome_icon_list_get_selection (GNOME_ICON_LIST (bar));
+ p = g_list_reverse (p);
+
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);
+ if (GPOINTER_TO_INT (p->data) != num) {
+ num = GPOINTER_TO_INT (p->data);
+ attachment = E_MSG_COMPOSER_ATTACHMENT (g_list_nth_data (bar->priv->attachments, num));
+
+ 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);
+ }
+ remove_attachment (bar, attachment);
+ }
}
-
- for (p = attachment_list; p != NULL; p = p->next)
- remove_attachment (bar, E_MSG_COMPOSER_ATTACHMENT (p->data));
-
- g_list_free (attachment_list);
-
+
update (bar);
}
@@ -831,7 +829,7 @@ e_msg_composer_attachment_bar_get_num_at
{
g_return_val_if_fail (bar != NULL, 0);
g_return_val_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar), 0);
-
+
return bar->priv->num_attachments;
}
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 14 Sep 2003 07:28:52 -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; rewrite this function to get more efficient; close
+ opened edit-dialog before remove attachment. [#48466]
+
2003-08-19 Jeffrey Stedfast <fejj ximian com>
* Original patch from David Woodhouse, but modified a bit by me.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]