Opened 5 years ago

Closed 5 years ago

#10773 closed bug (fixed)

Gradient color stop sorting is not stable.

Reported by: pulkomandy Owned by: stippi
Priority: normal Milestone: R1
Component: Kits/Interface Kit Version: R1/Development
Keywords: Cc:
Blocked By: Blocking: #10542
Has a Patch: no Platform: All

Description

Consider the following code used to create a stripped pattern using a BGradient:

gradient.AddColor(black, 0);
gradient.AddColor(black, 127);
gradient.AddColor(white, 127);
gradient.AddColor(white, 255);

In ConvertToScreenForDrawing, the gradient stops will be sorted using BList.Sort. The sorting algorithm is not stable, so the two middle stops may be swapped. There are two ways to fix this:

  • Implement a stable sorting algorithm (http://en.wikipedia.org/wiki/Category:Stable_sorts)
  • Remove the AddColorStop method index parameter and use code similar to AddColor to find the proper index, or make that method private. This would allow BGradient to keep the list sorted, and remove the need for sorting it later. The method is used only in app_server (for reading the gradient data from app_server link) and when unarchiving a gradient.

What is the preferred solution?

Change History (2)

comment:1 by pulkomandy, 5 years ago

Blocking: 10542 added

comment:2 by pulkomandy, 5 years ago

Resolution: fixed
Status: newclosed

Fixed in hrev47193.

Note: See TracTickets for help on using tickets.