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

 For Web Designers 2017-09-18 03:55:40 UTC Mail Delivery Problems? 

Sunday, February 03 2013

Curses::UI::Notebook Page Delete Bug, Part Two

Just a while ago I wrote about a bug in Curses::UI::Notebook delete_page. Well, shucks, I found another. This one will puke up the error The notebook already has a page named... whatever previously used and then deleted name you've chosen.

This bug manifests itself as widget (page) objects not actually being removed from the UI::Curses::Container object by UI::Curses::Notebook. The page/tab disappears but the object itself hangs around, so if you try to reuse the name your application dies. To duplicate:

There's more ...

→ committed: 2/3/2013 01:56:00

[ / perl_programming] permanent link

Comments: 0    Trackbacks: 0

   

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
       
     

By Month:

By category:

Feeds:

Served to 54.158.55.5:36006 at 03:55:40 GMT on Wednesday, October 18, 2017.

return(0.4881);