diff options
| author | Jan Djärv | 2003-02-02 18:54:32 +0000 |
|---|---|---|
| committer | Jan Djärv | 2003-02-02 18:54:32 +0000 |
| commit | 49853a4d5c1361ec09e53fbf06f4faea70820696 (patch) | |
| tree | 5709a6c22f632d2de3af2749275608af99932a84 /src | |
| parent | 769c4c6377fcdcb49c5e2ce11301d59ee675559b (diff) | |
| download | emacs-49853a4d5c1361ec09e53fbf06f4faea70820696.tar.gz emacs-49853a4d5c1361ec09e53fbf06f4faea70820696.zip | |
Fix memory leak.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/gtkutil.c | 184 |
2 files changed, 107 insertions, 84 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 7c98fb4b95b..d5ed10f6a51 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2003-02-02 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * gtkutil.c (remove_from_container): Copying list is not needed. | ||
| 4 | (xg_update_menubar, xg_update_menu_item, xg_update_submenu) | ||
| 5 | (xg_modify_menubar_widgets, update_frame_tool_bar): Call g_list_free | ||
| 6 | on list returned from gtk_container_get_children to avoid memory leak. | ||
| 7 | |||
| 1 | 2003-02-01 Jason Rumney <jasonr@gnu.org> | 8 | 2003-02-01 Jason Rumney <jasonr@gnu.org> |
| 2 | 9 | ||
| 3 | * w32fns.c (w32_create_pixmap_from_bitmap_data): Use alloca for | 10 | * w32fns.c (w32_create_pixmap_from_bitmap_data): Use alloca for |
diff --git a/src/gtkutil.c b/src/gtkutil.c index 4713d13d17a..c2da9a145e6 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -1576,11 +1576,9 @@ remove_from_container (wcont, list) | |||
| 1576 | GtkWidget *wcont; | 1576 | GtkWidget *wcont; |
| 1577 | GList *list; | 1577 | GList *list; |
| 1578 | { | 1578 | { |
| 1579 | /* We must copy list because gtk_container_remove changes it. */ | ||
| 1580 | GList *clist = g_list_copy (list); | ||
| 1581 | GList *iter; | 1579 | GList *iter; |
| 1582 | 1580 | ||
| 1583 | for (iter = clist; iter; iter = g_list_next (iter)) | 1581 | for (iter = list; iter; iter = g_list_next (iter)) |
| 1584 | { | 1582 | { |
| 1585 | GtkWidget *w = GTK_WIDGET (iter->data); | 1583 | GtkWidget *w = GTK_WIDGET (iter->data); |
| 1586 | 1584 | ||
| @@ -1595,39 +1593,44 @@ remove_from_container (wcont, list) | |||
| 1595 | removing the detached window also if there was one. */ | 1593 | removing the detached window also if there was one. */ |
| 1596 | gtk_widget_destroy (w); | 1594 | gtk_widget_destroy (w); |
| 1597 | } | 1595 | } |
| 1598 | g_list_free (clist); | ||
| 1599 | } | 1596 | } |
| 1600 | 1597 | ||
| 1601 | /* Update the top level names in MENUBAR (i.e. not submenus). | 1598 | /* Update the top level names in MENUBAR (i.e. not submenus). |
| 1602 | F is the frame the menu bar belongs to. | 1599 | F is the frame the menu bar belongs to. |
| 1603 | LIST is a list with the current menu bar names (menu item widgets). | 1600 | *LIST is a list with the current menu bar names (menu item widgets). |
| 1601 | ITER is the item within *LIST that shall be updated. | ||
| 1602 | POS is the numerical position, starting at 0, of ITER in *LIST. | ||
| 1604 | VAL describes what the menu bar shall look like after the update. | 1603 | VAL describes what the menu bar shall look like after the update. |
| 1605 | SELECT_CB is the callback to use when a menu item is selected. | 1604 | SELECT_CB is the callback to use when a menu item is selected. |
| 1606 | HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | 1605 | HIGHLIGHT_CB is the callback to call when entering/leaving menu items. |
| 1606 | CL_DATA points to the callback data to be used for this menu bar. | ||
| 1607 | 1607 | ||
| 1608 | This function calls itself to walk through the menu bar names. */ | 1608 | This function calls itself to walk through the menu bar names. */ |
| 1609 | static void | 1609 | static void |
| 1610 | xg_update_menubar (menubar, f, list, val, select_cb, highlight_cb, cl_data) | 1610 | xg_update_menubar (menubar, f, list, iter, pos, val, |
| 1611 | select_cb, highlight_cb, cl_data) | ||
| 1611 | GtkWidget *menubar; | 1612 | GtkWidget *menubar; |
| 1612 | FRAME_PTR f; | 1613 | FRAME_PTR f; |
| 1613 | GList *list; | 1614 | GList **list; |
| 1615 | GList *iter; | ||
| 1616 | int pos; | ||
| 1614 | widget_value *val; | 1617 | widget_value *val; |
| 1615 | GCallback select_cb; | 1618 | GCallback select_cb; |
| 1616 | GCallback highlight_cb; | 1619 | GCallback highlight_cb; |
| 1617 | xg_menu_cb_data *cl_data; | 1620 | xg_menu_cb_data *cl_data; |
| 1618 | { | 1621 | { |
| 1619 | if (! list && ! val) | 1622 | if (! iter && ! val) |
| 1620 | return; | 1623 | return; |
| 1621 | else if (list && ! val) | 1624 | else if (iter && ! val) |
| 1622 | { | 1625 | { |
| 1623 | /* Item(s) have been removed. Remove all remaining items from list. */ | 1626 | /* Item(s) have been removed. Remove all remaining items. */ |
| 1624 | remove_from_container (menubar, list); | 1627 | remove_from_container (menubar, iter); |
| 1625 | 1628 | ||
| 1626 | /* All updated. */ | 1629 | /* All updated. */ |
| 1627 | val = 0; | 1630 | val = 0; |
| 1628 | list = 0; | 1631 | iter = 0; |
| 1629 | } | 1632 | } |
| 1630 | else if (! list && val) | 1633 | else if (! iter && val) |
| 1631 | { | 1634 | { |
| 1632 | /* Item(s) added. Add all new items in one call. */ | 1635 | /* Item(s) added. Add all new items in one call. */ |
| 1633 | create_menus (val, f, select_cb, 0, highlight_cb, | 1636 | create_menus (val, f, select_cb, 0, highlight_cb, |
| @@ -1635,51 +1638,43 @@ xg_update_menubar (menubar, f, list, val, select_cb, highlight_cb, cl_data) | |||
| 1635 | 1638 | ||
| 1636 | /* All updated. */ | 1639 | /* All updated. */ |
| 1637 | val = 0; | 1640 | val = 0; |
| 1638 | list = 0; | 1641 | iter = 0; |
| 1639 | } | 1642 | } |
| 1640 | /* Below this neither list or val is NULL */ | 1643 | /* Below this neither iter or val is NULL */ |
| 1641 | else if (xg_item_label_same_p (GTK_MENU_ITEM (list->data), val->name)) | 1644 | else if (xg_item_label_same_p (GTK_MENU_ITEM (iter->data), val->name)) |
| 1642 | { | 1645 | { |
| 1643 | /* This item is still the same, check next item. */ | 1646 | /* This item is still the same, check next item. */ |
| 1644 | val = val->next; | 1647 | val = val->next; |
| 1645 | list = g_list_next (list); | 1648 | iter = g_list_next (iter); |
| 1649 | ++pos; | ||
| 1646 | } | 1650 | } |
| 1647 | else /* This item is changed. */ | 1651 | else /* This item is changed. */ |
| 1648 | { | 1652 | { |
| 1649 | GtkMenuItem *witem = GTK_MENU_ITEM (list->data); | 1653 | GtkMenuItem *witem = GTK_MENU_ITEM (iter->data); |
| 1650 | GtkMenuItem *witem2 = 0; | 1654 | GtkMenuItem *witem2 = 0; |
| 1651 | int pos = 0; | ||
| 1652 | int val_in_menubar = 0; | 1655 | int val_in_menubar = 0; |
| 1653 | int list_in_new_menubar = 0; | 1656 | int iter_in_new_menubar = 0; |
| 1654 | GList *list2; | 1657 | GList *iter2; |
| 1655 | GList *iter; | ||
| 1656 | widget_value *cur; | 1658 | widget_value *cur; |
| 1657 | 1659 | ||
| 1658 | |||
| 1659 | /* Get position number for witem. */ | ||
| 1660 | list2 = gtk_container_get_children (GTK_CONTAINER (menubar)); | ||
| 1661 | for (iter = list2; iter; iter = g_list_next (iter)) | ||
| 1662 | { | ||
| 1663 | if (list->data == iter->data) break; | ||
| 1664 | ++pos; | ||
| 1665 | } | ||
| 1666 | |||
| 1667 | /* See if the changed entry (val) is present later in the menu bar */ | 1660 | /* See if the changed entry (val) is present later in the menu bar */ |
| 1668 | for (iter = g_list_next (list); | 1661 | for (iter2 = iter; |
| 1669 | iter && ! val_in_menubar; | 1662 | iter2 && ! val_in_menubar; |
| 1670 | iter = g_list_next (iter)) | 1663 | iter2 = g_list_next (iter2)) |
| 1671 | { | 1664 | { |
| 1672 | witem2 = GTK_MENU_ITEM (iter->data); | 1665 | witem2 = GTK_MENU_ITEM (iter2->data); |
| 1673 | val_in_menubar = xg_item_label_same_p (witem2, val->name); | 1666 | val_in_menubar = xg_item_label_same_p (witem2, val->name); |
| 1674 | } | 1667 | } |
| 1675 | 1668 | ||
| 1676 | /* See if the current entry (list) is present later in the | 1669 | /* See if the current entry (iter) is present later in the |
| 1677 | specification for the new menu bar. */ | 1670 | specification for the new menu bar. */ |
| 1678 | for (cur = val; cur && ! list_in_new_menubar; cur = cur->next) | 1671 | for (cur = val; cur && ! iter_in_new_menubar; cur = cur->next) |
| 1679 | list_in_new_menubar = xg_item_label_same_p (witem, cur->name); | 1672 | iter_in_new_menubar = xg_item_label_same_p (witem, cur->name); |
| 1680 | 1673 | ||
| 1681 | if (val_in_menubar && ! list_in_new_menubar) | 1674 | if (val_in_menubar && ! iter_in_new_menubar) |
| 1682 | { | 1675 | { |
| 1676 | int nr = pos; | ||
| 1677 | |||
| 1683 | /* This corresponds to: | 1678 | /* This corresponds to: |
| 1684 | Current: A B C | 1679 | Current: A B C |
| 1685 | New: A C | 1680 | New: A C |
| @@ -1690,10 +1685,11 @@ xg_update_menubar (menubar, f, list, val, select_cb, highlight_cb, cl_data) | |||
| 1690 | gtk_widget_destroy (GTK_WIDGET (witem)); | 1685 | gtk_widget_destroy (GTK_WIDGET (witem)); |
| 1691 | 1686 | ||
| 1692 | /* Must get new list since the old changed. */ | 1687 | /* Must get new list since the old changed. */ |
| 1693 | list = gtk_container_get_children (GTK_CONTAINER (menubar)); | 1688 | g_list_free (*list); |
| 1694 | while (pos-- > 0) list = g_list_next (list); | 1689 | *list = iter = gtk_container_get_children (GTK_CONTAINER (menubar)); |
| 1690 | while (nr-- > 0) iter = g_list_next (iter); | ||
| 1695 | } | 1691 | } |
| 1696 | else if (! val_in_menubar && ! list_in_new_menubar) | 1692 | else if (! val_in_menubar && ! iter_in_new_menubar) |
| 1697 | { | 1693 | { |
| 1698 | /* This corresponds to: | 1694 | /* This corresponds to: |
| 1699 | Current: A B C | 1695 | Current: A B C |
| @@ -1714,16 +1710,18 @@ xg_update_menubar (menubar, f, list, val, select_cb, highlight_cb, cl_data) | |||
| 1714 | 1710 | ||
| 1715 | gtk_label_set_text_with_mnemonic (wlabel, utf8_label); | 1711 | gtk_label_set_text_with_mnemonic (wlabel, utf8_label); |
| 1716 | 1712 | ||
| 1717 | list = g_list_next (list); | 1713 | iter = g_list_next (iter); |
| 1718 | val = val->next; | 1714 | val = val->next; |
| 1715 | ++pos; | ||
| 1719 | } | 1716 | } |
| 1720 | else if (! val_in_menubar && list_in_new_menubar) | 1717 | else if (! val_in_menubar && iter_in_new_menubar) |
| 1721 | { | 1718 | { |
| 1722 | /* This corresponds to: | 1719 | /* This corresponds to: |
| 1723 | Current: A B C | 1720 | Current: A B C |
| 1724 | New: A X B C | 1721 | New: A X B C |
| 1725 | Insert X. */ | 1722 | Insert X. */ |
| 1726 | 1723 | ||
| 1724 | int nr = pos; | ||
| 1727 | GList *group = 0; | 1725 | GList *group = 0; |
| 1728 | GtkWidget *w = xg_create_one_menuitem (val, | 1726 | GtkWidget *w = xg_create_one_menuitem (val, |
| 1729 | f, | 1727 | f, |
| @@ -1735,13 +1733,16 @@ xg_update_menubar (menubar, f, list, val, select_cb, highlight_cb, cl_data) | |||
| 1735 | gtk_widget_set_name (w, MENU_ITEM_NAME); | 1733 | gtk_widget_set_name (w, MENU_ITEM_NAME); |
| 1736 | gtk_menu_shell_insert (GTK_MENU_SHELL (menubar), w, pos); | 1734 | gtk_menu_shell_insert (GTK_MENU_SHELL (menubar), w, pos); |
| 1737 | 1735 | ||
| 1738 | list = gtk_container_get_children (GTK_CONTAINER (menubar)); | 1736 | g_list_free (*list); |
| 1739 | while (pos-- > 0) list = g_list_next (list); | 1737 | *list = iter = gtk_container_get_children (GTK_CONTAINER (menubar)); |
| 1740 | list = g_list_next (list); | 1738 | while (nr-- > 0) iter = g_list_next (iter); |
| 1739 | iter = g_list_next (iter); | ||
| 1741 | val = val->next; | 1740 | val = val->next; |
| 1741 | ++pos; | ||
| 1742 | } | 1742 | } |
| 1743 | else /* if (val_in_menubar && list_in_new_menubar) */ | 1743 | else /* if (val_in_menubar && iter_in_new_menubar) */ |
| 1744 | { | 1744 | { |
| 1745 | int nr = pos; | ||
| 1745 | /* This corresponds to: | 1746 | /* This corresponds to: |
| 1746 | Current: A B C | 1747 | Current: A B C |
| 1747 | New: A C B | 1748 | New: A C B |
| @@ -1753,16 +1754,17 @@ xg_update_menubar (menubar, f, list, val, select_cb, highlight_cb, cl_data) | |||
| 1753 | GTK_WIDGET (witem2), pos); | 1754 | GTK_WIDGET (witem2), pos); |
| 1754 | gtk_widget_unref (GTK_WIDGET (witem2)); | 1755 | gtk_widget_unref (GTK_WIDGET (witem2)); |
| 1755 | 1756 | ||
| 1757 | g_list_free (*list); | ||
| 1758 | *list = iter = gtk_container_get_children (GTK_CONTAINER (menubar)); | ||
| 1759 | while (nr-- > 0) iter = g_list_next (iter); | ||
| 1756 | val = val->next; | 1760 | val = val->next; |
| 1757 | list = gtk_container_get_children (GTK_CONTAINER (menubar)); | 1761 | ++pos; |
| 1758 | while (pos-- > 0) list = g_list_next (list); | ||
| 1759 | list = g_list_next (list); | ||
| 1760 | } | 1762 | } |
| 1761 | |||
| 1762 | } | 1763 | } |
| 1763 | 1764 | ||
| 1764 | /* Update the rest of the menu bar. */ | 1765 | /* Update the rest of the menu bar. */ |
| 1765 | xg_update_menubar (menubar, f, list, val, select_cb, highlight_cb, cl_data); | 1766 | xg_update_menubar (menubar, f, list, iter, pos, val, |
| 1767 | select_cb, highlight_cb, cl_data); | ||
| 1766 | } | 1768 | } |
| 1767 | 1769 | ||
| 1768 | /* Update the menu item W so it corresponds to VAL. | 1770 | /* Update the menu item W so it corresponds to VAL. |
| @@ -1797,6 +1799,8 @@ xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) | |||
| 1797 | 1799 | ||
| 1798 | wlbl = GTK_LABEL (list->data); | 1800 | wlbl = GTK_LABEL (list->data); |
| 1799 | wkey = GTK_LABEL (list->next->data); | 1801 | wkey = GTK_LABEL (list->next->data); |
| 1802 | g_list_free (list); | ||
| 1803 | |||
| 1800 | if (! utf8_key) | 1804 | if (! utf8_key) |
| 1801 | { | 1805 | { |
| 1802 | /* Remove the key and keep just the label. */ | 1806 | /* Remove the key and keep just the label. */ |
| @@ -1805,6 +1809,7 @@ xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) | |||
| 1805 | gtk_container_add (GTK_CONTAINER (w), GTK_WIDGET (wlbl)); | 1809 | gtk_container_add (GTK_CONTAINER (w), GTK_WIDGET (wlbl)); |
| 1806 | wkey = 0; | 1810 | wkey = 0; |
| 1807 | } | 1811 | } |
| 1812 | |||
| 1808 | } | 1813 | } |
| 1809 | else /* Just a label. */ | 1814 | else /* Just a label. */ |
| 1810 | { | 1815 | { |
| @@ -1815,8 +1820,10 @@ xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) | |||
| 1815 | { | 1820 | { |
| 1816 | GtkWidget *wtoadd = make_widget_for_menu_item (utf8_label, utf8_key); | 1821 | GtkWidget *wtoadd = make_widget_for_menu_item (utf8_label, utf8_key); |
| 1817 | GList *list = gtk_container_get_children (GTK_CONTAINER (wtoadd)); | 1822 | GList *list = gtk_container_get_children (GTK_CONTAINER (wtoadd)); |
| 1823 | |||
| 1818 | wlbl = GTK_LABEL (list->data); | 1824 | wlbl = GTK_LABEL (list->data); |
| 1819 | wkey = GTK_LABEL (list->next->data); | 1825 | wkey = GTK_LABEL (list->next->data); |
| 1826 | g_list_free (list); | ||
| 1820 | 1827 | ||
| 1821 | gtk_container_remove (GTK_CONTAINER (w), wchild); | 1828 | gtk_container_remove (GTK_CONTAINER (w), wchild); |
| 1822 | gtk_container_add (GTK_CONTAINER (w), wtoadd); | 1829 | gtk_container_add (GTK_CONTAINER (w), wtoadd); |
| @@ -2056,6 +2063,8 @@ xg_update_submenu (submenu, f, val, | |||
| 2056 | 0); | 2063 | 0); |
| 2057 | } | 2064 | } |
| 2058 | 2065 | ||
| 2066 | if (list) g_list_free (list); | ||
| 2067 | |||
| 2059 | return newsub; | 2068 | return newsub; |
| 2060 | } | 2069 | } |
| 2061 | 2070 | ||
| @@ -2080,7 +2089,6 @@ xg_modify_menubar_widgets (menubar, f, val, deep_p, | |||
| 2080 | { | 2089 | { |
| 2081 | xg_menu_cb_data *cl_data; | 2090 | xg_menu_cb_data *cl_data; |
| 2082 | GList *list = gtk_container_get_children (GTK_CONTAINER (menubar)); | 2091 | GList *list = gtk_container_get_children (GTK_CONTAINER (menubar)); |
| 2083 | GList *iter; | ||
| 2084 | 2092 | ||
| 2085 | if (! list) return; | 2093 | if (! list) return; |
| 2086 | 2094 | ||
| @@ -2090,7 +2098,7 @@ xg_modify_menubar_widgets (menubar, f, val, deep_p, | |||
| 2090 | if (! deep_p) | 2098 | if (! deep_p) |
| 2091 | { | 2099 | { |
| 2092 | widget_value *cur = val->contents; | 2100 | widget_value *cur = val->contents; |
| 2093 | xg_update_menubar (menubar, f, list, cur, | 2101 | xg_update_menubar (menubar, f, &list, list, 0, cur, |
| 2094 | select_cb, highlight_cb, cl_data); | 2102 | select_cb, highlight_cb, cl_data); |
| 2095 | } | 2103 | } |
| 2096 | else | 2104 | else |
| @@ -2106,6 +2114,7 @@ xg_modify_menubar_widgets (menubar, f, val, deep_p, | |||
| 2106 | 2114 | ||
| 2107 | for (cur = val->contents; cur; cur = cur->next) | 2115 | for (cur = val->contents; cur; cur = cur->next) |
| 2108 | { | 2116 | { |
| 2117 | GList *iter; | ||
| 2109 | GtkWidget *sub = 0; | 2118 | GtkWidget *sub = 0; |
| 2110 | GtkWidget *newsub; | 2119 | GtkWidget *newsub; |
| 2111 | GtkMenuItem *witem; | 2120 | GtkMenuItem *witem; |
| @@ -2137,6 +2146,7 @@ xg_modify_menubar_widgets (menubar, f, val, deep_p, | |||
| 2137 | } | 2146 | } |
| 2138 | } | 2147 | } |
| 2139 | 2148 | ||
| 2149 | g_list_free (list); | ||
| 2140 | gtk_widget_show_all (menubar); | 2150 | gtk_widget_show_all (menubar); |
| 2141 | } | 2151 | } |
| 2142 | 2152 | ||
| @@ -2424,34 +2434,35 @@ xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height) | |||
| 2424 | int width; | 2434 | int width; |
| 2425 | int height; | 2435 | int height; |
| 2426 | { | 2436 | { |
| 2427 | GtkWidget *wscroll = xg_get_widget_from_map (scrollbar_id); | ||
| 2428 | 2437 | ||
| 2429 | if (wscroll) | 2438 | GtkWidget *wscroll = xg_get_widget_from_map (scrollbar_id); |
| 2430 | { | 2439 | |
| 2431 | int gheight = max (height, 1); | 2440 | if (wscroll) |
| 2441 | { | ||
| 2442 | int gheight = max (height, 1); | ||
| 2432 | 2443 | ||
| 2433 | gtk_fixed_move (GTK_FIXED (f->output_data.x->edit_widget), | 2444 | gtk_fixed_move (GTK_FIXED (f->output_data.x->edit_widget), |
| 2434 | wscroll, left, top); | 2445 | wscroll, left, top); |
| 2435 | 2446 | ||
| 2436 | gtk_widget_set_size_request (wscroll, width, gheight); | 2447 | gtk_widget_set_size_request (wscroll, width, gheight); |
| 2437 | 2448 | ||
| 2438 | /* Must force out update so wscroll gets the resize. | 2449 | /* Must force out update so wscroll gets the resize. |
| 2439 | Otherwise, the gdk_window_clear clears the old window size. */ | 2450 | Otherwise, the gdk_window_clear clears the old window size. */ |
| 2440 | gdk_window_process_all_updates (); | 2451 | gdk_window_process_all_updates (); |
| 2441 | 2452 | ||
| 2442 | /* The scroll bar doesn't explicitly redraw the whole window | 2453 | /* The scroll bar doesn't explicitly redraw the whole window |
| 2443 | when a resize occurs. Since the scroll bar seems to be fixed | 2454 | when a resize occurs. Since the scroll bar seems to be fixed |
| 2444 | in width it doesn't fill the space reserved, so we must clear | 2455 | in width it doesn't fill the space reserved, so we must clear |
| 2445 | the whole window. */ | 2456 | the whole window. */ |
| 2446 | gdk_window_clear (wscroll->window); | 2457 | gdk_window_clear (wscroll->window); |
| 2447 | 2458 | ||
| 2448 | /* Since we are not using a pure gtk event loop, we must force out | 2459 | /* Since we are not using a pure gtk event loop, we must force out |
| 2449 | pending update events with this call. */ | 2460 | pending update events with this call. */ |
| 2450 | gdk_window_process_all_updates (); | 2461 | gdk_window_process_all_updates (); |
| 2451 | 2462 | ||
| 2452 | SET_FRAME_GARBAGED (f); | 2463 | SET_FRAME_GARBAGED (f); |
| 2453 | cancel_mouse_face (f); | 2464 | cancel_mouse_face (f); |
| 2454 | } | 2465 | } |
| 2455 | } | 2466 | } |
| 2456 | 2467 | ||
| 2457 | /* Set the thumb size and position of scroll bar BAR. We are currently | 2468 | /* Set the thumb size and position of scroll bar BAR. We are currently |
| @@ -2698,6 +2709,7 @@ update_frame_tool_bar (f) | |||
| 2698 | int i; | 2709 | int i; |
| 2699 | GtkRequisition old_req, new_req; | 2710 | GtkRequisition old_req, new_req; |
| 2700 | GList *icon_list; | 2711 | GList *icon_list; |
| 2712 | GList *iter; | ||
| 2701 | struct x_output *x = f->output_data.x; | 2713 | struct x_output *x = f->output_data.x; |
| 2702 | 2714 | ||
| 2703 | if (! FRAME_GTK_WIDGET (f)) | 2715 | if (! FRAME_GTK_WIDGET (f)) |
| @@ -2711,7 +2723,8 @@ update_frame_tool_bar (f) | |||
| 2711 | gtk_widget_size_request (x->toolbar_widget, &old_req); | 2723 | gtk_widget_size_request (x->toolbar_widget, &old_req); |
| 2712 | 2724 | ||
| 2713 | icon_list = gtk_container_get_children (GTK_CONTAINER (x->toolbar_widget)); | 2725 | icon_list = gtk_container_get_children (GTK_CONTAINER (x->toolbar_widget)); |
| 2714 | 2726 | iter = icon_list; | |
| 2727 | |||
| 2715 | for (i = 0; i < f->n_tool_bar_items; ++i) | 2728 | for (i = 0; i < f->n_tool_bar_items; ++i) |
| 2716 | { | 2729 | { |
| 2717 | #define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX)) | 2730 | #define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX)) |
| @@ -2722,9 +2735,9 @@ update_frame_tool_bar (f) | |||
| 2722 | int img_id; | 2735 | int img_id; |
| 2723 | struct image *img; | 2736 | struct image *img; |
| 2724 | Lisp_Object image; | 2737 | Lisp_Object image; |
| 2725 | GtkWidget *wicon = icon_list ? GTK_WIDGET (icon_list->data) : 0; | 2738 | GtkWidget *wicon = iter ? GTK_WIDGET (iter->data) : 0; |
| 2726 | 2739 | ||
| 2727 | if (icon_list) icon_list = g_list_next (icon_list); | 2740 | if (iter) iter = g_list_next (iter); |
| 2728 | 2741 | ||
| 2729 | /* If image is a vector, choose the image according to the | 2742 | /* If image is a vector, choose the image according to the |
| 2730 | button state. */ | 2743 | button state. */ |
| @@ -2812,10 +2825,11 @@ update_frame_tool_bar (f) | |||
| 2812 | /* The child of the tool bar is a button. Inside that button | 2825 | /* The child of the tool bar is a button. Inside that button |
| 2813 | is a vbox. Inside that vbox is the GtkImage. */ | 2826 | is a vbox. Inside that vbox is the GtkImage. */ |
| 2814 | GtkWidget *wvbox = gtk_bin_get_child (GTK_BIN (wicon)); | 2827 | GtkWidget *wvbox = gtk_bin_get_child (GTK_BIN (wicon)); |
| 2815 | GList *ch = gtk_container_get_children (GTK_CONTAINER (wvbox)); | 2828 | GList *chlist = gtk_container_get_children (GTK_CONTAINER (wvbox)); |
| 2816 | GtkImage *wimage = GTK_IMAGE (ch->data); | 2829 | GtkImage *wimage = GTK_IMAGE (chlist->data); |
| 2817 | struct image *old_img = g_object_get_data (G_OBJECT (wimage), | 2830 | struct image *old_img = g_object_get_data (G_OBJECT (wimage), |
| 2818 | XG_TOOL_BAR_IMAGE_DATA); | 2831 | XG_TOOL_BAR_IMAGE_DATA); |
| 2832 | g_list_free (chlist); | ||
| 2819 | 2833 | ||
| 2820 | if (! old_img | 2834 | if (! old_img |
| 2821 | || old_img->pixmap != img->pixmap | 2835 | || old_img->pixmap != img->pixmap |
| @@ -2840,11 +2854,11 @@ update_frame_tool_bar (f) | |||
| 2840 | 2854 | ||
| 2841 | /* Remove buttons not longer needed. We just hide them so they | 2855 | /* Remove buttons not longer needed. We just hide them so they |
| 2842 | can be reused later on. */ | 2856 | can be reused later on. */ |
| 2843 | while (icon_list) | 2857 | while (iter) |
| 2844 | { | 2858 | { |
| 2845 | GtkWidget *w = GTK_WIDGET (icon_list->data); | 2859 | GtkWidget *w = GTK_WIDGET (iter->data); |
| 2846 | gtk_widget_hide (w); | 2860 | gtk_widget_hide (w); |
| 2847 | icon_list = g_list_next (icon_list); | 2861 | iter = g_list_next (iter); |
| 2848 | } | 2862 | } |
| 2849 | 2863 | ||
| 2850 | gtk_widget_size_request (x->toolbar_widget, &new_req); | 2864 | gtk_widget_size_request (x->toolbar_widget, &new_req); |
| @@ -2857,6 +2871,8 @@ update_frame_tool_bar (f) | |||
| 2857 | /* Must force out update so changed images gets redrawn. */ | 2871 | /* Must force out update so changed images gets redrawn. */ |
| 2858 | gdk_window_process_all_updates (); | 2872 | gdk_window_process_all_updates (); |
| 2859 | 2873 | ||
| 2874 | if (icon_list) g_list_free (icon_list); | ||
| 2875 | |||
| 2860 | UNBLOCK_INPUT; | 2876 | UNBLOCK_INPUT; |
| 2861 | } | 2877 | } |
| 2862 | 2878 | ||