mirror of https://github.com/GNOME/gimp.git
app: use GWeakRef instead of g_object_add_weak_pointer().
Other than multi-threading (which here is not the problem), using
GWeakRef has the other advantage that it makes the type of pointer
obvious, hence avoiding the kind of errors as fixed in commit 12df796
.
One can't just change the pointer value directly, and has to use
g_weak_ref_set(), so such problem won't happen again.
This commit is contained in:
parent
12df7960ad
commit
7be856a47d
|
@ -392,6 +392,7 @@ gimp_gegl_tool_dialog (GimpFilterTool *filter_tool)
|
|||
GtkWidget *main_vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *combo;
|
||||
GtkWidget *options_gui;
|
||||
GList *opclasses;
|
||||
GList *iter;
|
||||
|
||||
|
@ -474,17 +475,15 @@ gimp_gegl_tool_dialog (GimpFilterTool *filter_tool)
|
|||
gtk_box_reorder_child (GTK_BOX (main_vbox), tool->description_label, 1);
|
||||
|
||||
/* The options vbox */
|
||||
o_tool->options_gui =
|
||||
gtk_label_new (_("Select an operation from the list above"));
|
||||
g_object_add_weak_pointer (G_OBJECT (o_tool->options_gui),
|
||||
(gpointer) &o_tool->options_gui);
|
||||
gimp_label_set_attributes (GTK_LABEL (o_tool->options_gui),
|
||||
options_gui = gtk_label_new (_("Select an operation from the list above"));
|
||||
gimp_label_set_attributes (GTK_LABEL (options_gui),
|
||||
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
||||
-1);
|
||||
gtk_misc_set_padding (GTK_MISC (o_tool->options_gui), 0, 4);
|
||||
gtk_misc_set_padding (GTK_MISC (options_gui), 0, 4);
|
||||
gtk_container_add (GTK_CONTAINER (o_tool->options_box),
|
||||
o_tool->options_gui);
|
||||
gtk_widget_show (o_tool->options_gui);
|
||||
options_gui);
|
||||
g_weak_ref_set (&o_tool->options_gui_ref, options_gui);
|
||||
gtk_widget_show (options_gui);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -188,13 +188,19 @@ gimp_operation_tool_initialize (GimpTool *tool,
|
|||
|
||||
if (filter_tool->config)
|
||||
{
|
||||
gimp_operation_tool_sync_op (op_tool, TRUE);
|
||||
GtkWidget *options_gui;
|
||||
|
||||
if (! op_tool->options_gui)
|
||||
gimp_operation_tool_sync_op (op_tool, TRUE);
|
||||
options_gui = g_weak_ref_get (&op_tool->options_gui_ref);
|
||||
if (! options_gui)
|
||||
{
|
||||
gimp_operation_tool_create_gui (op_tool);
|
||||
gimp_operation_tool_add_gui (op_tool);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_object_unref (options_gui);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -273,6 +279,7 @@ gimp_operation_tool_dialog (GimpFilterTool *filter_tool)
|
|||
{
|
||||
GimpOperationTool *op_tool = GIMP_OPERATION_TOOL (filter_tool);
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *options_gui;
|
||||
|
||||
main_vbox = gimp_filter_tool_dialog_get_vbox (filter_tool);
|
||||
|
||||
|
@ -285,8 +292,12 @@ gimp_operation_tool_dialog (GimpFilterTool *filter_tool)
|
|||
g_object_add_weak_pointer (G_OBJECT (op_tool->options_box),
|
||||
(gpointer) &op_tool->options_box);
|
||||
|
||||
if (op_tool->options_gui)
|
||||
gimp_operation_tool_add_gui (op_tool);
|
||||
options_gui = g_weak_ref_get (&op_tool->options_gui_ref);
|
||||
if (options_gui)
|
||||
{
|
||||
gimp_operation_tool_add_gui (op_tool);
|
||||
g_object_unref (options_gui);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -497,13 +508,14 @@ static void
|
|||
gimp_operation_tool_create_gui (GimpOperationTool *op_tool)
|
||||
{
|
||||
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (op_tool);
|
||||
GtkWidget *options_gui;
|
||||
gint off_x, off_y;
|
||||
GeglRectangle area;
|
||||
gint aux;
|
||||
|
||||
gimp_filter_tool_get_drawable_area (filter_tool, &off_x, &off_y, &area);
|
||||
|
||||
op_tool->options_gui =
|
||||
options_gui =
|
||||
gimp_prop_gui_new (G_OBJECT (filter_tool->config),
|
||||
G_TYPE_FROM_INSTANCE (filter_tool->config), 0,
|
||||
&area,
|
||||
|
@ -511,9 +523,7 @@ gimp_operation_tool_create_gui (GimpOperationTool *op_tool)
|
|||
(GimpCreatePickerFunc) gimp_filter_tool_add_color_picker,
|
||||
(GimpCreateControllerFunc) gimp_filter_tool_add_controller,
|
||||
filter_tool);
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (op_tool->options_gui),
|
||||
(gpointer) &op_tool->options_gui);
|
||||
g_weak_ref_set (&op_tool->options_gui_ref, options_gui);
|
||||
|
||||
for (aux = 1; ; aux++)
|
||||
{
|
||||
|
@ -554,8 +564,12 @@ static void
|
|||
gimp_operation_tool_add_gui (GimpOperationTool *op_tool)
|
||||
{
|
||||
GtkSizeGroup *size_group = NULL;
|
||||
GtkWidget *options_gui;
|
||||
GList *list;
|
||||
|
||||
options_gui = g_weak_ref_get (&op_tool->options_gui_ref);
|
||||
g_return_if_fail (options_gui);
|
||||
|
||||
for (list = op_tool->aux_inputs; list; list = g_list_next (list))
|
||||
{
|
||||
AuxInput *input = list->data;
|
||||
|
@ -577,9 +591,10 @@ gimp_operation_tool_add_gui (GimpOperationTool *op_tool)
|
|||
if (size_group)
|
||||
g_object_unref (size_group);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (op_tool->options_box), op_tool->options_gui,
|
||||
gtk_box_pack_start (GTK_BOX (op_tool->options_box), options_gui,
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show (op_tool->options_gui);
|
||||
gtk_widget_show (options_gui);
|
||||
g_object_unref (options_gui);
|
||||
}
|
||||
|
||||
|
||||
|
@ -682,6 +697,7 @@ gimp_operation_tool_set_operation (GimpOperationTool *op_tool,
|
|||
{
|
||||
GimpTool *tool;
|
||||
GimpFilterTool *filter_tool;
|
||||
GtkWidget *options_gui;
|
||||
|
||||
g_return_if_fail (GIMP_IS_OPERATION_TOOL (op_tool));
|
||||
|
||||
|
@ -705,11 +721,12 @@ gimp_operation_tool_set_operation (GimpOperationTool *op_tool,
|
|||
|
||||
gimp_filter_tool_set_widget (filter_tool, NULL);
|
||||
|
||||
if (op_tool->options_gui)
|
||||
options_gui = g_weak_ref_get (&op_tool->options_gui_ref);
|
||||
if (options_gui)
|
||||
{
|
||||
gimp_filter_tool_disable_color_picking (filter_tool);
|
||||
|
||||
gtk_widget_destroy (op_tool->options_gui);
|
||||
g_object_unref (options_gui);
|
||||
gtk_widget_destroy (options_gui);
|
||||
}
|
||||
|
||||
if (! operation)
|
||||
|
|
|
@ -44,7 +44,7 @@ struct _GimpOperationTool
|
|||
|
||||
/* dialog */
|
||||
GtkWidget *options_box;
|
||||
GtkWidget *options_gui;
|
||||
GWeakRef options_gui_ref;
|
||||
};
|
||||
|
||||
struct _GimpOperationToolClass
|
||||
|
|
Loading…
Reference in New Issue