Gnome::Spell problems



I've been trying to get the Gnome::Spell widget to work, but
it has been crashing my application shortly after using it.

I reduced it to the simplest case possible, a text area that pops up a spell
checking dialog.  The code is reproduced below. Upon running the program, one
can enter text into the textarea, then try to spell check it, you can just close
the dialog and or try checking the document a couple more times and it crashes
on my system with a segmentation fault in perl.

It is probably because I am not closing something properly, but
I can't find it.  Ideas?  I'm using the CVS version of GtkPerl from
around Jun 13th and gnome-libs-1.2.11.

Here is the code :

#!/usr/bin/perl -w

use Gnome;

Gnome->init("Spell Check");
$app = new Gnome::App("Spell Check", "Spell Check");
$text_area = new Gtk::Text(undef, undef);
$text_area->set_editable('1');
$vbox = new Gtk::VBox(0,0);
$button = new_with_label Gtk::Button("Spellcheck");
$vbox->pack_start($text_area,1,1,0);
$vbox->pack_start($button,0,0,0);
$app->set_contents($vbox);
$button->signal_connect('clicked', \&Check_Spell, $text_area);
$app->signal_connect('delete_event', sub { &Gtk::main_quit(); });
$app->signal_connect('destroy', sub { &Gtk::false; });
$app->show_all;

Gtk->main;

sub Check_Spell {
   my ( $widget, $text_area ) = @_;

   $w = new Gnome::Dialog("spell-check");
   $b = new_with_label Gtk::Button("Quit");
   $sp = new Gnome::Spell;
   $sp->signal_connect('found_word', sub {
        my ($s, $i) = @_;
        print "FOUND WORD: $i->{word}\n";
        print "ALTERNATIVES: ", join(" ", @{$i->{words}}), "\n" if defined $i->{words};
   });
   $w->vbox->pack_start($sp,1,1,0);
   $w->vbox->pack_start($b,0,0,0);
   $w->signal_connect('destroy', sub { $sp->kill; $w->destroy; });
   $w->signal_connect('delete_event', sub { $sp->kill; $w->destroy; });
   $b->signal_connect('clicked', sub { $sp->kill; $w->destroy; });
   $w->show_all;

   $sp->check($text_area->get_chars(0,-1));
}

Andrew Schretter
Systems Programmer, Duke University
Dept. of Mathematics (919) 660-2866






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