mirror of https://github.com/GNOME/gimp.git
app: limit color-history palette size
Limit the color-history palette size (currently, to 256 colors), to avoid slowdowns, especially during loading.
This commit is contained in:
parent
e60829767e
commit
07b7d63a7d
|
@ -34,6 +34,7 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define MAX_N_COLORS 256
|
||||
#define RGBA_EPSILON 1e-4
|
||||
|
||||
enum
|
||||
|
@ -116,10 +117,13 @@ gimp_palette_mru_load (GimpPaletteMru *mru,
|
|||
GimpRGB color;
|
||||
|
||||
if (! gimp_scanner_parse_color (scanner, &color))
|
||||
goto error;
|
||||
goto end;
|
||||
|
||||
gimp_palette_add_entry (palette, -1,
|
||||
_("History Color"), &color);
|
||||
|
||||
if (gimp_palette_get_n_colors (palette) == MAX_N_COLORS)
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
token = G_TOKEN_RIGHT_PAREN;
|
||||
|
@ -134,7 +138,7 @@ gimp_palette_mru_load (GimpPaletteMru *mru,
|
|||
}
|
||||
}
|
||||
|
||||
error:
|
||||
end:
|
||||
gimp_scanner_destroy (scanner);
|
||||
}
|
||||
|
||||
|
@ -215,5 +219,12 @@ gimp_palette_mru_add (GimpPaletteMru *mru,
|
|||
}
|
||||
}
|
||||
|
||||
if (gimp_palette_get_n_colors (palette) == MAX_N_COLORS)
|
||||
{
|
||||
gimp_palette_delete_entry (palette,
|
||||
gimp_palette_get_entry (palette,
|
||||
MAX_N_COLORS - 1));
|
||||
}
|
||||
|
||||
gimp_palette_add_entry (palette, 0, _("History Color"), color);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue