Commit 2dffdbeb authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

removed assertion about proc_rec != NULL because that happens when

2004-09-22  Michael Natterer  <mitch@gimp.org>

	* app/plug-in/plug-in-proc-frame.[ch] (plug_in_proc_frame_init):
	removed assertion about proc_rec != NULL because that happens
	when query()ing and init()int plug-ins.

	Replaced "context" by "main_context" plus "context_stack".

	* app/plug-in/plug-in-context.c: implement plug_in_context_push()
	and plug_in_context_pop().

	* app/plug-in/plug-in-message.c
	* app/plug-in/plug-in-progress.c: changed accordingly.

	* tools/pdbgen/pdb/context.pdb: use the return values of
	plug_in_context_push() and _pop().

	* app/pdb/context_cmds.c: regenerated.

	* plug-ins/script-fu/scripts/test-sphere.scm: use
	gimp-context-push and gimp-context-pop instead of remembering the
	old values for FG, BG etc.
parent 4069dd9d
2004-09-22 Michael Natterer <mitch@gimp.org>
* app/plug-in/plug-in-proc-frame.[ch] (plug_in_proc_frame_init):
removed assertion about proc_rec != NULL because that happens
when query()ing and init()int plug-ins.
Replaced "context" by "main_context" plus "context_stack".
* app/plug-in/plug-in-context.c: implement plug_in_context_push()
and plug_in_context_pop().
* app/plug-in/plug-in-message.c
* app/plug-in/plug-in-progress.c: changed accordingly.
* tools/pdbgen/pdb/context.pdb: use the return values of
plug_in_context_push() and _pop().
* app/pdb/context_cmds.c: regenerated.
* plug-ins/script-fu/scripts/test-sphere.scm: use
gimp-context-push and gimp-context-pop instead of remembering the
old values for FG, BG etc.
2004-09-22 Sven Neumann <sven@gimp.org>
* tools/pdbgen/Makefile.am
......
......@@ -27,6 +27,7 @@
#include "procedural_db.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "plug-in/plug-in-context.h"
#include "plug-in/plug-in.h"
......@@ -49,7 +50,7 @@ context_push_invoker (Gimp *gimp,
gboolean success = TRUE;
if (gimp->current_plug_in && gimp->current_plug_in->open)
{
plug_in_context_push (gimp->current_plug_in);
success = plug_in_context_push (gimp->current_plug_in);
}
else
success = FALSE;
......@@ -81,7 +82,7 @@ context_pop_invoker (Gimp *gimp,
gboolean success = TRUE;
if (gimp->current_plug_in && gimp->current_plug_in->open)
{
plug_in_context_push (gimp->current_plug_in);
success = plug_in_context_push (gimp->current_plug_in);
}
else
success = FALSE;
......
......@@ -23,6 +23,7 @@
#include "plug-in-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "plug-in.h"
#include "plug-in-context.h"
......@@ -32,11 +33,24 @@ gboolean
plug_in_context_push (PlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
GimpContext *parent;
GimpContext *context;
g_return_val_if_fail (plug_in != NULL, FALSE);
proc_frame = plug_in_get_proc_frame (plug_in);
if (proc_frame->context_stack)
parent = proc_frame->context_stack->data;
else
parent = proc_frame->main_context;
context = gimp_context_new (plug_in->gimp, "plug-in context", NULL);
gimp_context_copy_properties (parent, context, GIMP_CONTEXT_ALL_PROPS_MASK);
proc_frame->context_stack = g_list_prepend (proc_frame->context_stack,
context);
return TRUE;
}
......@@ -49,5 +63,16 @@ plug_in_context_pop (PlugIn *plug_in)
proc_frame = plug_in_get_proc_frame (plug_in);
return TRUE;
if (proc_frame->context_stack)
{
GimpContext *context = proc_frame->context_stack->data;
proc_frame->context_stack = g_list_remove (proc_frame->context_stack,
context);
g_object_unref (context);
return TRUE;
}
return FALSE;
}
......@@ -387,7 +387,10 @@ plug_in_handle_proc_run (PlugIn *plug_in,
/* Execute the procedure even if procedural_db_lookup() returned NULL,
* procedural_db_execute() will return appropriate error return_vals.
*/
return_vals = procedural_db_execute (plug_in->gimp, proc_frame->context,
return_vals = procedural_db_execute (plug_in->gimp,
proc_frame->context_stack ?
proc_frame->context_stack->data :
proc_frame->main_context,
proc_frame->progress,
proc_name, args);
......@@ -435,6 +438,11 @@ plug_in_handle_proc_run (PlugIn *plug_in,
{
PlugInBlocked *blocked;
g_warning ("%s: EEEEEEEEEK! \n"
"You managed to trigger a code path that \n"
"should be dead. Please report this to bugs.gimp.org.",
G_STRFUNC);
blocked = g_new0 (PlugInBlocked, 1);
blocked->plug_in = plug_in;
......@@ -467,6 +475,11 @@ plug_in_handle_proc_return_priv (PlugIn *plug_in,
{
GSList *list;
g_warning ("%s: EEEEEEEEEK! \n"
"You managed to trigger a code path that \n"
"should be dead. Please report this to bugs.gimp.org.",
G_STRFUNC);
for (list = blocked_plug_ins; list; list = g_slist_next (list))
{
PlugInBlocked *blocked;
......
......@@ -176,7 +176,7 @@ plug_in_progress_install (PlugIn *plug_in,
}
proc_frame->progress = g_object_new (GIMP_TYPE_PDB_PROGRESS,
"context", proc_frame->context,
"context", proc_frame->main_context,
"callback-name", progress_callback,
NULL);
......
......@@ -60,9 +60,9 @@ plug_in_proc_frame_init (PlugInProcFrame *proc_frame,
g_return_if_fail (proc_frame != NULL);
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
g_return_if_fail (proc_rec != NULL);
proc_frame->context = g_object_ref (context);
proc_frame->main_context = g_object_ref (context);
proc_frame->context_stack = NULL;
proc_frame->proc_rec = proc_rec;
proc_frame->main_loop = NULL;
proc_frame->return_vals = NULL;
......@@ -90,10 +90,17 @@ plug_in_proc_frame_dispose (PlugInProcFrame *proc_frame,
}
}
if (proc_frame->context)
if (proc_frame->context_stack)
{
g_object_unref (proc_frame->context);
proc_frame->context = NULL;
g_list_foreach (proc_frame->context_stack, (GFunc) g_object_unref, NULL);
g_list_free (proc_frame->context_stack);
proc_frame->context_stack = NULL;
}
if (proc_frame->main_context)
{
g_object_unref (proc_frame->main_context);
proc_frame->main_context = NULL;
}
}
......
......@@ -24,7 +24,8 @@
struct _PlugInProcFrame
{
GimpContext *context;
GimpContext *main_context;
GList *context_stack;
ProcRecord *proc_rec;
GMainLoop *main_loop;
......
......@@ -23,6 +23,7 @@
#include "plug-in-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "plug-in.h"
#include "plug-in-context.h"
......@@ -32,11 +33,24 @@ gboolean
plug_in_context_push (PlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
GimpContext *parent;
GimpContext *context;
g_return_val_if_fail (plug_in != NULL, FALSE);
proc_frame = plug_in_get_proc_frame (plug_in);
if (proc_frame->context_stack)
parent = proc_frame->context_stack->data;
else
parent = proc_frame->main_context;
context = gimp_context_new (plug_in->gimp, "plug-in context", NULL);
gimp_context_copy_properties (parent, context, GIMP_CONTEXT_ALL_PROPS_MASK);
proc_frame->context_stack = g_list_prepend (proc_frame->context_stack,
context);
return TRUE;
}
......@@ -49,5 +63,16 @@ plug_in_context_pop (PlugIn *plug_in)
proc_frame = plug_in_get_proc_frame (plug_in);
return TRUE;
if (proc_frame->context_stack)
{
GimpContext *context = proc_frame->context_stack->data;
proc_frame->context_stack = g_list_remove (proc_frame->context_stack,
context);
g_object_unref (context);
return TRUE;
}
return FALSE;
}
......@@ -387,7 +387,10 @@ plug_in_handle_proc_run (PlugIn *plug_in,
/* Execute the procedure even if procedural_db_lookup() returned NULL,
* procedural_db_execute() will return appropriate error return_vals.
*/
return_vals = procedural_db_execute (plug_in->gimp, proc_frame->context,
return_vals = procedural_db_execute (plug_in->gimp,
proc_frame->context_stack ?
proc_frame->context_stack->data :
proc_frame->main_context,
proc_frame->progress,
proc_name, args);
......@@ -435,6 +438,11 @@ plug_in_handle_proc_run (PlugIn *plug_in,
{
PlugInBlocked *blocked;
g_warning ("%s: EEEEEEEEEK! \n"
"You managed to trigger a code path that \n"
"should be dead. Please report this to bugs.gimp.org.",
G_STRFUNC);
blocked = g_new0 (PlugInBlocked, 1);
blocked->plug_in = plug_in;
......@@ -467,6 +475,11 @@ plug_in_handle_proc_return_priv (PlugIn *plug_in,
{
GSList *list;
g_warning ("%s: EEEEEEEEEK! \n"
"You managed to trigger a code path that \n"
"should be dead. Please report this to bugs.gimp.org.",
G_STRFUNC);
for (list = blocked_plug_ins; list; list = g_slist_next (list))
{
PlugInBlocked *blocked;
......
......@@ -60,9 +60,9 @@ plug_in_proc_frame_init (PlugInProcFrame *proc_frame,
g_return_if_fail (proc_frame != NULL);
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
g_return_if_fail (proc_rec != NULL);
proc_frame->context = g_object_ref (context);
proc_frame->main_context = g_object_ref (context);
proc_frame->context_stack = NULL;
proc_frame->proc_rec = proc_rec;
proc_frame->main_loop = NULL;
proc_frame->return_vals = NULL;
......@@ -90,10 +90,17 @@ plug_in_proc_frame_dispose (PlugInProcFrame *proc_frame,
}
}
if (proc_frame->context)
if (proc_frame->context_stack)
{
g_object_unref (proc_frame->context);
proc_frame->context = NULL;
g_list_foreach (proc_frame->context_stack, (GFunc) g_object_unref, NULL);
g_list_free (proc_frame->context_stack);
proc_frame->context_stack = NULL;
}
if (proc_frame->main_context)
{
g_object_unref (proc_frame->main_context);
proc_frame->main_context = NULL;
}
}
......
......@@ -24,7 +24,8 @@
struct _PlugInProcFrame
{
GimpContext *context;
GimpContext *main_context;
GList *context_stack;
ProcRecord *proc_rec;
GMainLoop *main_loop;
......
......@@ -176,7 +176,7 @@ plug_in_progress_install (PlugIn *plug_in,
}
proc_frame->progress = g_object_new (GIMP_TYPE_PDB_PROGRESS,
"context", proc_frame->context,
"context", proc_frame->main_context,
"callback-name", progress_callback,
NULL);
......
......@@ -144,11 +144,9 @@
(offset (* radius 0.1))
(text-extents (gimp-text-get-extents-fontname text size PIXELS font))
(x-position (- cx (/ (car text-extents) 2)))
(y-position (- cy (/ (cadr text-extents) 2)))
(old-pattern (car (gimp-patterns-get-pattern)))
(old-gradient (car (gimp-gradients-get-gradient)))
(old-fg (car (gimp-palette-get-foreground)))
(old-bg (car (gimp-palette-get-background))))
(y-position (- cy (/ (cadr text-extents) 2))))
(gimp-context-push)
(gimp-image-undo-disable img)
(gimp-image-add-layer img drawable 0)
......@@ -203,12 +201,10 @@
size PIXELS
font)))
(gimp-gradients-set-gradient old-gradient)
(gimp-patterns-set-pattern old-pattern)
(gimp-palette-set-background old-bg)
(gimp-palette-set-foreground old-fg)
(gimp-image-undo-enable img)
(gimp-display-new img)))
(gimp-display-new img)
(gimp-context-pop)))
(script-fu-register "script-fu-test-sphere"
"<Toolbox>/Xtns/Script-Fu/Test/_Sphere..."
......
......@@ -40,7 +40,7 @@ HELP
{
if (gimp->current_plug_in && gimp->current_plug_in->open)
{
plug_in_context_push (gimp->current_plug_in);
success = plug_in_context_push (gimp->current_plug_in);
}
else
success = FALSE;
......@@ -64,7 +64,7 @@ HELP
{
if (gimp->current_plug_in && gimp->current_plug_in->open)
{
plug_in_context_push (gimp->current_plug_in);
success = plug_in_context_push (gimp->current_plug_in);
}
else
success = FALSE;
......@@ -73,7 +73,8 @@ CODE
);
}
@headers = qw("core/gimp.h" "plug-in/plug-in.h" "plug-in/plug-in-context.h");
@headers = qw("core/gimp.h" "core/gimpcontext.h"
"plug-in/plug-in.h" "plug-in/plug-in-context.h");
@procs = qw(context_push context_pop);
%exports = (app => [@procs], lib => [@procs]);
......
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