Perl Programmer/Consultant
Remote System Administrator
Free Software
... contact me
 
  while ($making_other_plans) { life(); }
  location('ipsstb', '2013', '02', '02');

 For Web Designers 2021-05-19 14:31:00 UTC Mail Delivery Problems? 

Saturday, February 02 2013

Curses::UI::Notebook Delete Page Bug

The Problem: Curses::UI::Notebook delete_page() crashes the application.


  #!/usr/bin/perl

  use strict;
  use Curses::UI;

  my $ui = Curses::UI->new();

  my $win = $ui->add('win1', 'Window',
    -border => 0,
    -y      => 0,
    -bfg    => 'blue',
  );

  my $notebook = $win->add(undef, 'Notebook');

  my $p1 = $notebook->add_page('Page 1');
  $p1 -> add(undef, 'Label',
    -x    => 1,
    -y    => 1,
    -text => "This is Page One",
  );

  my $p2 = $notebook->add_page('Page 2');
  $p2 -> add(undef, 'Label',
    -x    => 1,
    -y    => 1,
    -text => "This is Page Two",
  );

  # Now the fun part:
  $ui->set_timer(
    'delete_active_page',
    sub {
      $notebook->delete_page($notebook->active_page());
      $_[0]->delete_timer('delete_active_page');
    },
    5
  );
  # What we expect to happen is that five seconds into runtime, the
  # currently active page will disappear.
  #
  # What ACTUALLY happens is that the application crashes.

  $ui->set_binding( sub { $ui->mainloopExit() }, "\cQ" );

  $notebook->focus();
  $ui->mainloop();

Never mind the use of the undocumented features set_timer() and delete_timer() for now. I'll 'splain 'em momentarily. They're very handy. I'm a source code reading fool but if you haven't seen it yet I'll save you the bother. First, though:

There's more ...

→ committed: 2/2/2013 19:03:50

[ / perl_programming] permanent link

Comments: 0    Trackbacks: 0

   
Save the Net

Creative Commons License

Project Honeypot Member

 
February 2013
Mon Tue Wed Thu Fri Sat Sun
        2
     

By Month:

By category:

Feeds:

Served to 44.192.253.106:42834 at 14:31:00 GMT on Saturday, June 19, 2021.

return(0.5045);