Bug 794378 - GIMP crashed while I was moving the image window

Use a weak pointer in GimpToolGui to not keep a dangling
private->viewable around.
This commit is contained in:
Michael Natterer 2018-03-20 19:01:17 +01:00
parent c44f5a2f4c
commit 9a365eaf8b
1 changed files with 18 additions and 3 deletions

View File

@ -160,6 +160,9 @@ gimp_tool_gui_dispose (GObject *object)
if (private->shell)
gimp_tool_gui_set_shell (GIMP_TOOL_GUI (object), NULL);
if (private->viewable)
gimp_tool_gui_set_viewable (GIMP_TOOL_GUI (object), NULL);
g_clear_object (&private->vbox);
if (private->dialog)
@ -419,15 +422,23 @@ gimp_tool_gui_set_viewable (GimpToolGui *gui,
GimpToolGuiPrivate *private;
g_return_if_fail (GIMP_IS_TOOL_GUI (gui));
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
g_return_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable));
private = GET_PRIVATE (gui);
if (private->viewable == viewable)
return;
if (private->viewable)
g_object_remove_weak_pointer (G_OBJECT (private->viewable),
(gpointer) &private->viewable);
private->viewable = viewable;
if (private->viewable)
g_object_add_weak_pointer (G_OBJECT (private->viewable),
(gpointer) &private->viewable);
gimp_tool_gui_update_viewable (gui);
}
@ -883,9 +894,13 @@ gimp_tool_gui_update_viewable (GimpToolGui *gui)
if (! private->overlay)
{
GimpContext *context = NULL;
if (private->tool_info)
context = GIMP_CONTEXT (private->tool_info->tool_options);
gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (private->dialog),
private->viewable,
GIMP_CONTEXT (private->tool_info->tool_options));
private->viewable, context);
}
}