[Pidgin] #10641: perl add_choice adds same choices within a loop

Pidgin trac at pidgin.im
Sun Nov 1 18:09:20 EST 2009


#10641: perl add_choice adds same choices within a loop
-------------------+--------------------------------------------------------
Reporter:  rlazur  |        Type:  defect 
  Status:  new     |   Component:  plugins
 Version:  2.6.3   |    Keywords:  perl   
-------------------+--------------------------------------------------------
 I could not find any documentation to see if this was normal behavior for
 the add_choice sub-routine via Purple.pm...

 I  was trying to add dynamic choices to preferences with add_choice, but
 output was the same choice over and over. I made sure that my variables
 were output what I needed them to be, and found that the only issue could
 be with add_choice.

 Besides perl not being paid that much attention to, is this expected
 behavior or a bug?

 Basic example:

 {{{
     my $fdir = Purple::Prefs::get_string("/plugins/core/fortune/dir");
     if (-d $fdir) {
       my $fpref = Purple::PluginPref->new_with_name_and_label(
         "/plugins/core/fortune/file", "Fortune File");
       $fpref->set_type(1);

       opendir(DIR, $fdir);
       my @files = readdir(DIR);
       closedir(DIR);

       my $old;
       foreach my $file (@files) {
         if ($file =~ /^([A-Za-z0-9]+)$/) { # i know this regex isn't
 perfect...
           $fpref->add_choice($1, $1); # ERROR, output is always the same
           Purple::Debug::info("Fortune Plugin", "my choice = ".$1."\n"); #
 this is perfect output, not duplicate
         }
         $file = '';
       }
       $fpref->add_choice("Any", ""); # output is fine here
       $frame->add($fpref);
     }
 }}}

-- 
Ticket URL: <http://developer.pidgin.im/ticket/10641>
Pidgin <http://pidgin.im>
Pidgin


More information about the Tracker mailing list