Repository navigation
Read 12-digit tag colors as 16 bits per channel - #1567
Merged
Merged
Conversation
Gramps 3.4 and 4.0 stored tag colors with Gdk.Color.to_string(), i.e. #RRRRGGGGBBBB with four hex digits per channel, and Tag still defaults to #000000000000. hex12ToCss() and hex12ToHex6() parsed each group in base 32 and divided by 255, so such colors were shown wrongly (the example tree's green tag "complete" as turquoise) and the edit dialog fell back to #1f77b4, which was saved together with any other change. Parse each group as hexadecimal and divide by 257; hex6ToHex12() writes the same format. Fixes gramps-project#1566
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue
Closes #1566
What this changes
hex12ToCss()andhex12ToHex6()insrc/color.jsparse each 4-digit group as hexadecimal and divide by 257 (new helperhex4To8Bit()), and accept only hex digits.hex6ToHex12()writes the same format (#ff0000→#ffff00000000). It is only used in tests.hex12ToHex6()no longer needs the range check, since a 4-digit hex group always maps to 0–255.How it was tested
test/unit/color.test.js: 4 new tests with the values from the example tree (#076780873bf0→rgb(7, 128, 60),#efb60c280c28→rgb(239, 12, 12)), white and black, the picker value (#07803c), the written format and non-hex digits. All 4 fail onmain; the existing round-trip tests did not catch the bug because both directions used base 32.npm run lintandnpm test(63 files, 1180 tests) pass.completeis shown in green,rgb(7, 128, 60), instead ofrgb(29, 255, 255), and its edit dialog opens with#07803cinstead of#1f77b4.Before / after:
Drafted with an AI assistant.