From 3565e866080992d36ee21c103a364a8a2947c093 Mon Sep 17 00:00:00 2001 From: shawnlaffan Date: Thu, 1 Feb 2024 12:46:11 +1100 Subject: [PATCH] GUI::Legend: Don't overwrite cached colour metadata This can otherwise cause issues later on. --- lib/Biodiverse/GUI/Legend.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Biodiverse/GUI/Legend.pm b/lib/Biodiverse/GUI/Legend.pm index 730d97ccc..27a0367b9 100644 --- a/lib/Biodiverse/GUI/Legend.pm +++ b/lib/Biodiverse/GUI/Legend.pm @@ -1261,11 +1261,12 @@ sub set_colour_mode_from_list_and_index { my $labels = $indices_object->get_index_category_labels (index => $index) // {}; my $colours = $indices_object->get_index_category_colours (index => $index) // {}; $self->{categorical}{labels} = $labels; + # don't mess with the cached object foreach my $key (keys %$colours) { my $colour = $colours->{$key}; - $colours->{$key} = Gtk2::Gdk::Color->parse($colour); + next if blessed $colour; # sometimes they are already colour objects + $self->{categorical}{colours}{$key} = Gtk2::Gdk::Color->parse($colour); } - $self->{categorical}{colours} = $colours; } elsif (!$mode && $list =~ />>CANAPE>>/) { # special handling for CANAPE indices