[gimp] libgimpbase: return 0 for GIMP_UNIT_PIXEL in gimp_unit_get_factor().
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpbase: return 0 for GIMP_UNIT_PIXEL in gimp_unit_get_factor().
- Date: Sat, 17 Aug 2019 10:13:17 +0000 (UTC)
commit f705bfb3957fa20c65e4544fa09b58893eb7d768
Author: Jehan <jehan girinstud io>
Date: Sat Aug 17 12:07:31 2019 +0200
libgimpbase: return 0 for GIMP_UNIT_PIXEL in gimp_unit_get_factor().
Just as documented, pixel unit should always return factor 0. There is
no need to call _gimp_unit_vtable.unit_get_factor().
This is even more important as there is one implementation of
unit_get_factor() in core, and another in libgimp and the one in libgimp
is expecting unit to always be >= GIMP_UNIT_INCH. So we were getting
CRITICALs in libgimp when calling gimp_unit_get_factor() on pixel unit
(for instance when drawing a GimpRuler).
libgimpbase/gimpunit.c | 3 +++
1 file changed, 3 insertions(+)
---
diff --git a/libgimpbase/gimpunit.c b/libgimpbase/gimpunit.c
index e6f2df2c0b..2184861691 100644
--- a/libgimpbase/gimpunit.c
+++ b/libgimpbase/gimpunit.c
@@ -233,6 +233,9 @@ gimp_unit_get_factor (GimpUnit unit)
{
g_return_val_if_fail (_gimp_unit_vtable.unit_get_factor != NULL, 1.0);
+ if (unit == GIMP_UNIT_PIXEL)
+ return 0.0;
+
return _gimp_unit_vtable.unit_get_factor (unit);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]