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

 For Web Designers 2017-11-16 16:57:54 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

 
December 2017
Mon Tue Wed Thu Fri Sat Sun
       
16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

By Month:

By category:

Feeds:

Served to 54.221.136.62:35184 at 16:57:54 GMT on Saturday, December 16, 2017.

return(0.5191);