[gimp] app: gimp_container_get_name_array() should always return a GStrv.



commit 8c43e641e3c548b799ddf7370347cb020f041edc
Author: Jehan <jehan girinstud io>
Date:   Tue May 24 17:56:49 2022 +0200

    app: gimp_container_get_name_array() should always return a GStrv.
    
    Even if the container is empty, then we return a GStrv of length 1 (i.e.
    an array of length 1, terminating with NULL).
    
    In particular, it improves gimp_container_get_filtered_name_array() as
    well, and in turn various list-returning functions in libgimp. This
    makes the API more consistent after changes from commit 8eb7f6df9e9.
    
    Note that a NULL return can be acceptable for error cases, but an empty
    list because this is the expected result for the request should be an
    empty GStrv, not NULL.

 app/core/gimpcontainer.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
---
diff --git a/app/core/gimpcontainer.c b/app/core/gimpcontainer.c
index 4d8d1a030b..8718e1c7cd 100644
--- a/app/core/gimpcontainer.c
+++ b/app/core/gimpcontainer.c
@@ -1000,13 +1000,11 @@ gimp_container_get_name_array (GimpContainer *container)
 {
   gchar **names;
   gchar **iter;
-  gint length;
+  gint    length;
 
   g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
 
   length = gimp_container_get_n_children (container);
-  if (length == 0)
-    return NULL;
 
   names = iter = g_new0 (gchar *, length + 1);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]