[gimp] app: limit color-history palette size
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: limit color-history palette size
- Date: Wed, 7 Aug 2019 16:21:28 +0000 (UTC)
commit 07b7d63a7d623a5d984dd5f7bbad6c725c51d9e7
Author: Ell <ell_se yahoo com>
Date: Wed Aug 7 19:05:13 2019 +0300
app: limit color-history palette size
Limit the color-history palette size (currently, to 256 colors), to
avoid slowdowns, especially during loading.
app/core/gimppalettemru.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/app/core/gimppalettemru.c b/app/core/gimppalettemru.c
index 7ca33ff991..f68c4695a6 100644
--- a/app/core/gimppalettemru.c
+++ b/app/core/gimppalettemru.c
@@ -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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]