[gimp] app: make gimp_container_view_remove_container() more robust
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: make gimp_container_view_remove_container() more robust
- Date: Fri, 6 Jun 2014 20:52:29 +0000 (UTC)
commit c9fc83a9320ec4269651eb6e5a67a6ee53ce3220
Author: Michael Natterer <mitch gimp org>
Date: Fri Jun 6 22:43:30 2014 +0200
app: make gimp_container_view_remove_container() more robust
Don't special case on view_iface->model_is_tree and always run
gimp_container_view_remove_foreach(), also on the view's toplevel
container. Run gimp_container_view_clear_items() anyway on the
toplevel as an optimization, but with a big comment. This makes all
views (on list *and* tree models) behave the same way, and makes
view_iface->model_is_tree practically obsolete, will remove it later.
app/widgets/gimpcontainerview.c | 26 ++++++++++++--------------
1 files changed, 12 insertions(+), 14 deletions(-)
---
diff --git a/app/widgets/gimpcontainerview.c b/app/widgets/gimpcontainerview.c
index f761818..9ca053d 100644
--- a/app/widgets/gimpcontainerview.c
+++ b/app/widgets/gimpcontainerview.c
@@ -1072,14 +1072,10 @@ static void
gimp_container_view_remove_container (GimpContainerView *view,
GimpContainer *container)
{
- GimpContainerViewInterface *view_iface;
- GimpContainerViewPrivate *private;
+ GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
g_object_ref (container);
- view_iface = GIMP_CONTAINER_VIEW_GET_INTERFACE (view);
- private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
-
g_signal_handlers_disconnect_by_func (container,
gimp_container_view_add,
view);
@@ -1094,18 +1090,20 @@ gimp_container_view_remove_container (GimpContainerView *view,
{
gimp_tree_handler_disconnect (private->name_changed_handler);
private->name_changed_handler = NULL;
- }
- if (! view_iface->model_is_tree && container == private->container)
- {
+ /* optimization: when the toplevel container gets removed, call
+ * clear_items() which will get rid of all view widget stuff
+ * *and* empty private->item_hash, so below call to
+ * remove_foreach() will only disconnect all containers but not
+ * remove all items individually (because they are gone from
+ * item_hash).
+ */
gimp_container_view_clear_items (view);
}
- else
- {
- gimp_container_foreach (container,
- (GFunc) gimp_container_view_remove_foreach,
- view);
- }
+
+ gimp_container_foreach (container,
+ (GFunc) gimp_container_view_remove_foreach,
+ view);
g_object_unref (container);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]