babl: do not append space to the format name when explicitly set.
authorJehan <jehan@girinstud.io>
Wed, 3 Mar 2021 09:54:38 +0000 (10:54 +0100)
committerØyvind "pippin" Kolås <pippin@gimp.org>
Sat, 15 May 2021 20:57:03 +0000 (20:57 +0000)
commit4c7c2b75e56626a1270cd96f8951f0163ceb5451
treee3c5a59c528a29ec63c5b3ea019ec3a414688d4a
parent0a87f7316e5f67a51a097e15430639cd0b9badf3
babl: do not append space to the format name when explicitly set.

When a format is named explicitly by the caller, we should just keep the
same name, not tweak it. Generating a name is only valid when no
explicit name is given. Moreover this is the behavior as described in
the docs of babl_format_new():

> If no name is provided a (long) descriptive name is used.

(which usually implies that with a name provided, this one will be used
instead of a generated name)

This is especially important for palette formats for which name is
mostly not descriptive anyway (either caller-set or generated by babl
with incremental number) and this fixes a bug when calling
babl_new_palette_with_space() with the same name and space would fail to
find the already created formats (yet would find the models and return
NULL for both formats) because it would search without the space
description appended. Yet the docs of babl_new_palette*() clearly says
as well:

> If you pass in the same name the previous formats will be provided
> again.

Moreover we actually already tweak a bit the palette format name by
appending the space pointer. No need to tweak it twice appending the
same information (space) in a different way.

See also: https://gitlab.gnome.org/GNOME/gimp/-/issues/6501
babl/babl-format.c