summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-11-17 13:25:47 +0000
committerRichard Hughes <richard@hughsie.com>2014-11-17 13:28:28 +0000
commite67ff673c353c997193214dd5b20b0c47f513c77 (patch)
treec8f0a13de9a0aad5a9cd6c35eed294d697173d7a
parent7ed786ac2245559386c2308a9aab06f85d4eb00b (diff)
downloadcolord-e67ff673c353c997193214dd5b20b0c47f513c77.tar.gz
libcolord: When using cd_it8_add_spectrum() replace any with the same ID
-rw-r--r--lib/colord/cd-it8.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/colord/cd-it8.c b/lib/colord/cd-it8.c
index 3ee3578..cb0165b 100644
--- a/lib/colord/cd-it8.c
+++ b/lib/colord/cd-it8.c
@@ -1749,7 +1749,16 @@ cd_it8_set_spectrum_array (CdIt8 *it8, GPtrArray *data)
void
cd_it8_add_spectrum (CdIt8 *it8, CdSpectrum *spectrum)
{
+ CdSpectrum *tmp;
+
g_return_if_fail (CD_IS_IT8 (it8));
+
+ /* remove any existing spectra with this same ID */
+ tmp = cd_it8_get_spectrum_by_id (it8, cd_spectrum_get_id (spectrum));
+ if (tmp != NULL)
+ g_ptr_array_remove (it8->priv->array_spectra, tmp);
+
+ /* add this */
g_ptr_array_add (it8->priv->array_spectra, cd_spectrum_dup (spectrum));
}