[gimp/gimp-2-10] app: use a weak pointer for tool-manager active group
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: use a weak pointer for tool-manager active group
- Date: Sat, 1 Feb 2020 11:22:30 +0000 (UTC)
commit defc94972443c0ec2fd18bb120a623c701c8792c
Author: Ell <ell_se yahoo com>
Date: Sat Feb 1 12:41:11 2020 +0200
app: use a weak pointer for tool-manager active group
In GimpToolManager, use a weak pointer for tracking the active tool
group, instead of taking a reference on it. This avoids
erroneously extending the group's lifetime, which can cause
problems with the tool-item hierarchy.
In GimpToolGroup, make sure that newly-added tools don't already
have a parent.
(cherry picked from commit 30d833d00f2fd10480e8bf3542ea3c26004e7b73)
app/core/gimptoolgroup.c | 3 +++
app/tools/tool_manager.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/app/core/gimptoolgroup.c b/app/core/gimptoolgroup.c
index b9a412ee68..31d91b93f5 100644
--- a/app/core/gimptoolgroup.c
+++ b/app/core/gimptoolgroup.c
@@ -287,6 +287,9 @@ gimp_tool_group_child_add (GimpContainer *container,
GimpToolInfo *tool_info,
GimpToolGroup *tool_group)
{
+ g_return_if_fail (
+ gimp_viewable_get_parent (GIMP_VIEWABLE (tool_info)) == NULL);
+
gimp_viewable_set_parent (GIMP_VIEWABLE (tool_info),
GIMP_VIEWABLE (tool_group));
diff --git a/app/tools/tool_manager.c b/app/tools/tool_manager.c
index 7f4b31e3f5..3b8bc88a83 100644
--- a/app/tools/tool_manager.c
+++ b/app/tools/tool_manager.c
@@ -674,7 +674,7 @@ tool_manager_set_active_tool_group (GimpToolManager *tool_manager,
tool_manager);
}
- g_set_object (&tool_manager->active_tool_group, tool_group);
+ g_set_weak_pointer (&tool_manager->active_tool_group, tool_group);
if (tool_manager->active_tool_group)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]