app: explicitly clear GUI when halting a filter tool

In gimp_filter_tool_halt(), explicitly clear the GUI container
before clearing filter_tool->config, since the tool might be halted
during the GUI dialog's delete event, in which case the GUI will
only be implicitly destroyed *after* the function returns.  The
destruction of the GUI might fire signals whose handlers rely on
filter_tool->config, so we need to make sure it happens while it's
still alive.

In particular, this fixes a CRITICAL in the threshold tool, which
occurs due to the histogram view's "range-changhed" signal being
fired during its destruction, and its handler accessing
filter_tool->config.
This commit is contained in:
Ell 2018-08-20 14:21:11 -04:00
parent fd64aae47b
commit ec80a88513
1 changed files with 17 additions and 3 deletions

View File

@ -937,9 +937,23 @@ gimp_filter_tool_halt (GimpFilterTool *filter_tool)
{
GimpTool *tool = GIMP_TOOL (filter_tool);
g_clear_object (&filter_tool->gui);
filter_tool->settings_box = NULL;
filter_tool->region_combo = NULL;
if (filter_tool->gui)
{
/* explicitly clear the dialog contents first, since we might be called
* during the dialog's delete event, in which case the dialog will be
* externally reffed, and will only die *after* gimp_filter_tool_halt()
* returns, and, in particular, after filter_tool->config has been
* cleared. we want to make sure the gui is destroyed while
* filter_tool->config is still alive, since the gui's destruction may
* fire signals whose handlers rely on it.
*/
gimp_gtk_container_clear (
GTK_CONTAINER (gimp_filter_tool_dialog_get_vbox (filter_tool)));
g_clear_object (&filter_tool->gui);
filter_tool->settings_box = NULL;
filter_tool->region_combo = NULL;
}
if (filter_tool->filter)
{