Hi Mateusz, Mateusz Kijowski <mateusz.kijow...@gmail.com> writes: >> After perl and/or gtk2-perl update tyinyca started to sometimes >> generate certificates with options other than specified in the new >> certificate window.
I have not been able to reproduce this issue. Can you please provide more details how to reproduce it? You say that you get certificates with options different from those you selected, but only sometimes. Does it depend on your inputs in the certificate generation dialog? Is it random? >> After some investigation it turned out that the callback bound to >> 'toggled' signal was firing twice (presumably one for unchecking and >> one for checking the radio button) resulting in a race condition. That is the normal behavior of many GUI toolkits. I can see this leading to race conditions only when multi-threading has gone wrong. Tinyca uses only one thread, which is the same thread as that where the GUI main loop runs. The attached test program exercises a radio button group and the callbacks in one thread. The test is run by starting the program, then toggling the radio buttons with the mouse or by pressing and holding the <right> (or <left>) key and, after a little playing, clicking on the print button. The resulting output (in the console) shows the recorded 'toggled' signals. In all my tests the pattern of activations and deactivations was absolutely regular with no deactivation signal processed before the corresponding activation signal.
#!/usr/bin/perl -w use strict; use Time::HiRes qw( usleep ); use Glib qw/TRUE FALSE/; use Gtk2 -init; my $window = Gtk2::Window->new ('toplevel'); $window->signal_connect (delete_event => sub { Gtk2->main_quit }); my $box = Gtk2::HBox->new(FALSE, 2); my @radio_changes = []; my $countA = 0; my $countB = 0; my $radio1 = Gtk2::RadioButton->new(undef, "A"); $radio1->signal_connect('toggled' => sub{$countA++;\&record_change($radio1, $countA, \@radio_changes)}); my $radio2 = Gtk2::RadioButton->new($radio1, "B"); $radio2->signal_connect('toggled' => sub{$countB++;\&record_change($radio2, $countB, \@radio_changes)}); my $rb_group = $radio1->get_group(); my $button_print = Gtk2::Button->new("Print"); $button_print->signal_connect('button-release-event', \&print_state, \@radio_changes); $box->pack_start($radio1, FALSE, FALSE, 5); $box->pack_start($radio2, FALSE, FALSE, 5); $box->pack_start($button_print, FALSE, FALSE, 5); $window->add($box); $window->show_all(); Gtk2->main(); sub print_state { my ($widget, $event, $parameter) = @_; print STDOUT $widget, " received ", $event, ": ", $parameter; print STDOUT "\n"; foreach my $change (@$parameter) { print STDOUT $change, "\n"; } @$parameter = []; return FALSE; } sub record_change { my ($widget, $count, $changes) = @_; usleep(50000); # Wait for the race? my $change = $widget->get_active() ? "Activated" : "Deactivated"; push @$changes, $change." ".$widget->get_label().$count; return FALSE; }
>> The attached patch checks if the radio button is being set to active >> before assigning value to certificate options. Since >> GUI::_fill_radiobox() seems to be generic this might result in >> mangling other options controlled via radio buttons as well. I doubt that your patch will mangle other radio button-controlled options. But before I apply it I'd like to understand why it solves your issue. Regards Uli