Commit 7e1df2c8 authored by Michael Natterer's avatar Michael Natterer

app: add layers/channels/vectors freeze/thaw to gimpplugin-cleanup

so plug-ins cannot thaw what they haven't frozen, and the code
can clean up frozen stuff left behind by crashed or broken plug-ins.

Also redo the cleanup code so it only keeps track of the undo group
counts and freeze counts of what *this* GimpPlugInProcFrame did
itself. That should make it even stricter against broken code that
could mess up internals.
parent d87259cc
......@@ -53,6 +53,7 @@
#include "core/gimpselection.h"
#include "core/gimptempbuf.h"
#include "file/file-utils.h"
#include "plug-in/gimpplugin-cleanup.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h"
#include "vectors/gimpvectors.h"
......@@ -910,9 +911,14 @@ image_freeze_layers_invoker (GimpProcedure *procedure,
if (success)
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpContainer *container = gimp_image_get_layers (image);
gimp_container_freeze (container);
if (plug_in)
success = gimp_plug_in_cleanup_layers_freeze (plug_in, image);
if (success)
gimp_container_freeze (container);
}
return gimp_procedure_get_return_values (procedure, success,
......@@ -934,12 +940,17 @@ image_thaw_layers_invoker (GimpProcedure *procedure,
if (success)
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpContainer *container = gimp_image_get_layers (image);
if (gimp_container_frozen (container))
if (plug_in)
success = gimp_plug_in_cleanup_layers_thaw (plug_in, image);
if (success)
success = gimp_container_frozen (container);
if (success)
gimp_container_thaw (container);
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
......@@ -1064,9 +1075,14 @@ image_freeze_channels_invoker (GimpProcedure *procedure,
if (success)
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpContainer *container = gimp_image_get_channels (image);
gimp_container_freeze (container);
if (plug_in)
success = gimp_plug_in_cleanup_channels_freeze (plug_in, image);
if (success)
gimp_container_freeze (container);
}
return gimp_procedure_get_return_values (procedure, success,
......@@ -1088,12 +1104,17 @@ image_thaw_channels_invoker (GimpProcedure *procedure,
if (success)
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpContainer *container = gimp_image_get_channels (image);
if (gimp_container_frozen (container))
if (plug_in)
success = gimp_plug_in_cleanup_channels_thaw (plug_in, image);
if (success)
success = gimp_container_frozen (container);
if (success)
gimp_container_thaw (container);
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
......@@ -1218,9 +1239,14 @@ image_freeze_vectors_invoker (GimpProcedure *procedure,
if (success)
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpContainer *container = gimp_image_get_vectors (image);
gimp_container_freeze (container);
if (plug_in)
success = gimp_plug_in_cleanup_vectors_freeze (plug_in, image);
if (success)
gimp_container_freeze (container);
}
return gimp_procedure_get_return_values (procedure, success,
......@@ -1242,12 +1268,17 @@ image_thaw_vectors_invoker (GimpProcedure *procedure,
if (success)
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpContainer *container = gimp_image_get_vectors (image);
if (gimp_container_frozen (container))
if (plug_in)
success = gimp_plug_in_cleanup_vectors_thaw (plug_in, image);
if (success)
success = gimp_container_frozen (container);
if (success)
gimp_container_thaw (container);
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
......
This diff is collapsed.
......@@ -26,6 +26,21 @@ gboolean gimp_plug_in_cleanup_undo_group_start (GimpPlugIn *plug_in,
gboolean gimp_plug_in_cleanup_undo_group_end (GimpPlugIn *plug_in,
GimpImage *image);
gboolean gimp_plug_in_cleanup_layers_freeze (GimpPlugIn *plug_in,
GimpImage *image);
gboolean gimp_plug_in_cleanup_layers_thaw (GimpPlugIn *plug_in,
GimpImage *image);
gboolean gimp_plug_in_cleanup_channels_freeze (GimpPlugIn *plug_in,
GimpImage *image);
gboolean gimp_plug_in_cleanup_channels_thaw (GimpPlugIn *plug_in,
GimpImage *image);
gboolean gimp_plug_in_cleanup_vectors_freeze (GimpPlugIn *plug_in,
GimpImage *image);
gboolean gimp_plug_in_cleanup_vectors_thaw (GimpPlugIn *plug_in,
GimpImage *image);
gboolean gimp_plug_in_cleanup_add_shadow (GimpPlugIn *plug_in,
GimpDrawable *drawable);
gboolean gimp_plug_in_cleanup_remove_shadow (GimpPlugIn *plug_in,
......
......@@ -1044,9 +1044,14 @@ HELP
%invoke = (
code => <<'CODE'
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpContainer *container = gimp_image_get_layers (image);
gimp_container_freeze (container);
if (plug_in)
success = gimp_plug_in_cleanup_layers_freeze (plug_in, image);
if (success)
gimp_container_freeze (container);
}
CODE
);
......@@ -1074,12 +1079,17 @@ HELP
%invoke = (
code => <<'CODE'
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpContainer *container = gimp_image_get_layers (image);
if (gimp_container_frozen (container))
if (plug_in)
success = gimp_plug_in_cleanup_layers_thaw (plug_in, image);
if (success)
success = gimp_container_frozen (container);
if (success)
gimp_container_thaw (container);
else
success = FALSE;
}
CODE
);
......@@ -1214,9 +1224,14 @@ HELP
%invoke = (
code => <<'CODE'
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpContainer *container = gimp_image_get_channels (image);
gimp_container_freeze (container);
if (plug_in)
success = gimp_plug_in_cleanup_channels_freeze (plug_in, image);
if (success)
gimp_container_freeze (container);
}
CODE
);
......@@ -1244,12 +1259,17 @@ HELP
%invoke = (
code => <<'CODE'
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpContainer *container = gimp_image_get_channels (image);
if (gimp_container_frozen (container))
if (plug_in)
success = gimp_plug_in_cleanup_channels_thaw (plug_in, image);
if (success)
success = gimp_container_frozen (container);
if (success)
gimp_container_thaw (container);
else
success = FALSE;
}
CODE
);
......@@ -1382,9 +1402,14 @@ HELP
%invoke = (
code => <<'CODE'
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpContainer *container = gimp_image_get_vectors (image);
gimp_container_freeze (container);
if (plug_in)
success = gimp_plug_in_cleanup_vectors_freeze (plug_in, image);
if (success)
gimp_container_freeze (container);
}
CODE
);
......@@ -1412,12 +1437,17 @@ HELP
%invoke = (
code => <<'CODE'
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
GimpContainer *container = gimp_image_get_vectors (image);
if (gimp_container_frozen (container))
if (plug_in)
success = gimp_plug_in_cleanup_vectors_thaw (plug_in, image);
if (success)
success = gimp_container_frozen (container);
if (success)
gimp_container_thaw (container);
else
success = FALSE;
}
CODE
);
......@@ -3051,6 +3081,7 @@ CODE
"core/gimptempbuf.h"
"file/file-utils.h"
"plug-in/gimpplugin.h"
"plug-in/gimpplugin-cleanup.h"
"plug-in/gimppluginmanager.h"
"gimppdbcontext.h"
"gimppdberror.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment