shutter-project / shutter

Screenshot tool for Linux
https://shutter-project.org/
GNU General Public License v3.0
537 stars 35 forks source link

Fix for #453 #489

Closed Photon89 closed 1 year ago

Photon89 commented 2 years ago

We were hit by https://stackoverflow.com/questions/61765706/perl-sort-corrupts-bsd-glob-results

Photon89 commented 2 years ago

For some reason all profiles are shown as active when the menu entries are created, which seems similar to https://stackoverflow.com/questions/3394919/gtkradiobutton-set-active-and-deactive But I don't yet understand the root of the problem...

DarthGandalf commented 2 years ago

But I don't yet understand the root of the problem...

From your description it looks like they are assigned to different groups. And each of them is active in its own group

Photon89 commented 2 years ago

Maybe it does not interpret the $group argument correctly in https://github.com/Photon89/shutter/blob/532a02954964951258f322ae8f3716931a3e7110/bin/shutter#L8772 It should actually have two arguments according to documentation in https://docs.gtk.org/gtk3/ctor.RadioMenuItem.new_with_label.html and also according to the working demo in https://github.com/dave-theunsub/gtk3-perl-demos/blob/9b521bc03c7a266819d3e5e3f64df590092dccf4/menus.pl#L124 But if I remove the last argument, I get a segmentation fault with

undefined value for mandatory argument 'label' encountered at /usr/share/perl5/vendor_perl/Gtk3.pm line 1533.

while with three arguments it works (besides of all entries being marked as active.

DarthGandalf commented 2 years ago

That example has $group = $menuitem->get_group; unlike how we set $group

Photon89 commented 2 years ago

I tried to change it to the way it is defined in the example, but it doesn't have any effect.

Photon89 commented 2 years ago

So I am still stuck with this... I tried to make it work with two arguments, as it is stated in the docs, but I get the output


$profile: Bla

$group: ARRAY(0x55798aff69f8)

undefined value for mandatory argument 'label' encountered at /usr/share/perl5/vendor_perl/Gtk3.pm line 1533.
    Gtk3::__ANON__(ARRAY(0x55798aff69f8), "Bla") called at /usr/sbin/shutter line 8774
    Shutter::App::fct_ret_profile_menu(Gtk3::ComboBoxText=HASH(0x55798f52e7b8), ARRAY(0x55798cf91140)) called at /usr/sbin/shutter line 7115
    Shutter::App::fct_update_profile_selectors(Gtk3::ComboBoxText=HASH(0x55798f52e7b8), ARRAY(0x55798cf91140)) called at /usr/sbin/shutter line 2705
    Shutter::App::STARTUP(Shutter::App=HASH(0x55798efb2a48)) called at /usr/lib/perl5/5.36/vendor_perl/Glib/Object/Introspection.pm line 67
    Glib::Object::Introspection::__ANON__(Shutter::App=HASH(0x55798efb2a48)) called at /usr/sbin/shutter line 10955

from

[...]
        my $group   = [];
        my $counter = 0;
        foreach my $profile (@{$current_profiles_ref}) {
            print "\n\n\$profile: $profile\n\n";
            print "\n\n\$group: $group\n\n";
            my $profile_item = Gtk3::RadioMenuItem::new_with_label($group, $profile);
[...]

The label argument (second argument in Gtk3::RadioMenuItem::new_with_label) is set to $profile which is printed as "Bla" but the output claims that it has an undefined value...

Photon89 commented 2 years ago

Oh my gosh, I am stupid...

Photon89 commented 2 years ago

Ready for merging!