Bug 709 - Colors for PD annotation classes change randomly between runs
Summary: Colors for PD annotation classes change randomly between runs
Status: RESOLVED FIXED
Alias: None
Product: PulseView
Classification: Unclassified
Component: Data display (show other bugs)
Version: unreleased development snapshot
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Soeren Apel
URL:
Keywords: low_hanging_fruit
Depends on:
Blocks:
 
Reported: 2015-12-10 23:35 CET by Uwe Hermann
Modified: 2018-04-15 14:48 CEST (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Uwe Hermann 2015-12-10 23:35:20 CET
How to reproduce:

 - Start PV and load an .sr file, then run a PD on the data. E.g. jtag/olimex_stm32-h103/olimex_stm32-h103_idle.sr, add the JTAG decoder. Look at the colors of the first few annotations in the file.

 - Shutdown PV, start PV again, load the *same* .sr file, add the same JTAG decoder. The colors of the first few annotations will now be *different* than before.

This shouldn't happen and is confusing for the user. If settings/data stay the same, so should be annotation class colors.
Comment 1 Soeren Apel 2016-02-05 12:47:58 CET
The color is determined here: http://sigrok.org/gitweb/?p=pulseview.git;a=blob;f=pv/view/decodetrace.cpp;h=95e0e5e9ef0f2d4ddfd0692da1ab478846351190;hb=HEAD#l216

As the address of "this" is included in the hash, the color is pretty much random.
Comment 2 Soeren Apel 2016-04-17 22:40:41 CEST
Not quite as trivial to fix as I thought, will need to give it more thought. Reason is that the has function is really crappy and will create collisions (i.e. identical or visually identical colors) like crazy.

Currently I'm leaning towards kicking the hash function out and using a HSV-based algorithm instead, using different starting offsets into the hue range.
Comment 3 Uwe Hermann 2018-04-15 14:48:28 CEST
Fixed in 9ba13f5e933f55f015e7c592980dfad14b4c66a8, thanks!