[gimp-perl] Stop Gimp::Fu constantly doing set_trace(0). Bug 728233



commit 3fd7c84d70f87affe3b38fde579f509cb4c823a6
Author: Ed J <m8r-35s8eo mailinator com>
Date:   Tue Apr 15 03:31:28 2014 +0100

    Stop Gimp::Fu constantly doing set_trace(0). Bug 728233

 Gimp/Fu.pm |   37 ++++++++++++++++---------------------
 1 files changed, 16 insertions(+), 21 deletions(-)
---
diff --git a/Gimp/Fu.pm b/Gimp/Fu.pm
index a153ef2..7b45921 100644
--- a/Gimp/Fu.pm
+++ b/Gimp/Fu.pm
@@ -195,15 +195,14 @@ sub mangle_key {
 Gimp::on_net {
    no strict 'refs';
    my $this = this_script;
-   my(%map,@args);
+   my(%mangleparam2index,@args);
    my $interact = 1;
    $outputfile = undef;
 
    my($perl_sub,$function,$blurb,$help,$author,$copyright,$date,
       $menupath,$imagetypes,$params,$results,$code,$type)= $this;
 
-   # %map is a hash that associates (mangled) parameter names to parameter index
-   @map{map mangle_key($_->[1]), @{$params}} = (0..$#{$params});
+   @mangleparam2index{map mangle_key($_->[1]), @$params} = (0..$#{$params});
 
    # Parse the command line
    while(defined($_=shift @ARGV)) {
@@ -217,7 +216,7 @@ Gimp::on_net {
           exit 0;
         } else {
            my $arg=shift @ARGV;
-          my $idx=$map{$1};
+          my $idx=$mangleparam2index{$1};
           die __"$_: illegal switch, try $0 --help\n" unless defined($idx);
           $args[$idx]=string2pf($arg,$params->[$idx]);
           $interact--;
@@ -232,10 +231,10 @@ Gimp::on_net {
 
    # Fill in default arguments
    foreach my $i (0   $params-1) {
-       next if defined $args[$i];
-       my $entry = $params->[$i];
-       $args[$i] = $entry->[3];             # Default value
-       die __"parameter '$entry->[1]' is not optional\n" unless defined $args[$i] || $interact>0;
+      next if defined $args[$i];
+      my $entry = $params->[$i];
+      $args[$i] = $entry->[3];             # Default value
+      die __"parameter '$entry->[1]' is not optional\n" unless defined $args[$i] || $interact>0;
    }
 
    # Go for it
@@ -245,6 +244,15 @@ Gimp::on_net {
    );
 };
 
+sub datatype(@) {
+   warn __PACKAGE__."::datatype(@_)" if $Gimp::verbose;
+   for(@_) {
+      return Gimp::PDB_STRING unless /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/; # perlfaq4
+      return Gimp::PDB_FLOAT  unless /^[+-]?\d+$/; # again
+   }
+   return Gimp::PDB_INT32;
+}
+
 Gimp::on_query {
    expand_podsections;
    script:
@@ -259,15 +267,6 @@ Gimp::on_query {
          }
       }
 
-      sub datatype(@) {
-        warn __PACKAGE__."datatype(@_)" if $Gimp::verbose;
-         for(@_) {
-            return Gimp::PDB_STRING unless /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/; # perlfaq4
-            return Gimp::PDB_FLOAT  unless /^[+-]?\d+$/; # again
-         }
-         return Gimp::PDB_INT32;
-      }
-
       for(@$params) {
         next if $_->[0] < Gimp::PDB_END;
         $_->[0] = $pf2info{$_->[0]}->[1] // datatype(values %{+{ {$_->[4]}}});
@@ -427,9 +426,7 @@ sub register($$$$$$$$$;@) {
 
       print "$$-Gimp::Fu-generated sub: $function(",join(",",(@pre,@_)),")\n" if $Gimp::verbose;
 
-      Gimp::set_trace ($old_trace);
       my @retvals = $code->(@pre,@_);
-      $old_trace = Gimp::set_trace (0);
 
       if ($outputfile and $menupath !~ /^<Load>\//) {
         my @images = grep { defined $_ and ref $_ eq "Gimp::Image" } @retvals;
@@ -449,7 +446,6 @@ sub register($$$$$$$$$;@) {
         }
       }
 
-      Gimp::set_trace ($old_trace);
       wantarray ? @retvals : $retvals[0];
    };
 
@@ -513,7 +509,6 @@ sub save_image($$) {
 }
 
 sub main {
-   $old_trace = Gimp::set_trace (0);
    return Gimp::main unless $Gimp::help;
    my $this=this_script;
    print __<<EOF;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]