Fix crash when selecting pure black in the color picker when the recent colors list isn't full

Originally committed to SVN as r6534.
This commit is contained in:
Thomas Goyne 2012-03-07 01:31:04 +00:00
parent 110c2358a6
commit bb9859c70f

View file

@ -470,8 +470,11 @@ wxString ColorPickerRecent::StoreToString()
void ColorPickerRecent::AddColor(wxColour color)
{
colors.erase(remove(colors.begin(), colors.end(), color), colors.end());
colors.insert(colors.begin(), color);
std::vector<wxColour>::iterator existing = find(colors.begin(), colors.end(), color);
if (existing != colors.end())
rotate(colors.begin(), existing, existing + 1);
else
colors.insert(colors.begin(), color);
background_valid = false;