Hello, 

I'm not sure if I am understanding the new GimpContext functionality
correctly. I had hoped it would resolve issues that my Gimp Perl script
has with certain non-thread-safe resources when multiple instances of
the script are running concurrently.  For example one instance changing
the foreground color that another instance is using to render text.  It
happens infrequently but when I run multiple versions of a script with
code like the following I still see occasional images being rendered
with "incorrect" colors:

Gimp::init;
my $img = gimp_image_new(300, 200, 0);
gimp_context_push();
gimp_context_set_background([60, 108, 222]);

gimp_context_set_foreground([255,255,255]);
my $text_layer1A =   gimp_text_fontname($img,-1,0,0,"The Quick Brown
Fox", 0, 0, 14, 0, "Arial");
gimp_context_set_foreground([0,0,0]);
my $text_layer1B = gimp_text_fontname($img,-1,5,5,"Jumped Over the Lazy
Dog", 0, 0, 14, 0, "URW Gothic L");

gimp_context_set_foreground([237,16,16]);
my $text_layer2A = gimp_text_fontname($img,-1,0,20,"The Quick Brown
Fox", 0, 0, 14, 0, "Arial");
gimp_context_set_foreground([0,0,0]);
my $text_layer2B = gimp_text_fontname($img,-1,5,25,"Jumped Over the Lazy
Dog", 0, 0, 14, 0, "URW Gothic L");

... code to save image ...

gimp_context_pop();

Gimp::end;


Is there anything that takes place behind the scenes that makes sure
that each script is running in its own context?  Or does the call to
gimp_text_fontname simply use the latest context added to the stack,
allowing for something like script x switching to look at a context
pushed by script y while in the middle of executing calls to
gimp_text_fontname? I guess I'm looking for something more like:

my $context = gimp_create_context();
$context->set_foreground([255,255,255]);
# this call uses the context's foreground color
gimp_text_fontname($img,-1,0,0,"The Quick Brown Fox", 0, 0, 14, 0,
"Arial");
$context->delete();

I can see how push and pop would make sense for a plugin, but wonder if
there's an alternate way for batch image scripting to make use of it.


Thanks in advance,
Jared

________________________________________________________

Jared Whiting                        Myers Internet, Inc.
Senior Developer                    http://www.myers.com
(408) 428-9960 

"Taking Your Business To The Next Level"

_______________________________________________
Gimp-developer mailing list
Gimp-developer@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer

Reply via email to