[gtk/wip/chergert/spellcheck] spellcheck: return NULL if no langugaes were loaded



commit af7577e249ae3c63d1c5e011c5bc8e565aed897b
Author: Christian Hergert <chergert redhat com>
Date:   Mon Mar 15 15:05:56 2021 -0700

    spellcheck: return NULL if no langugaes were loaded

 gtk/gtkspellcheck.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkspellcheck.c b/gtk/gtkspellcheck.c
index 8ba3867131..fc64454dd4 100644
--- a/gtk/gtkspellcheck.c
+++ b/gtk/gtkspellcheck.c
@@ -268,9 +268,16 @@ gtk_spell_checker_new_for_language (const char *language)
 GtkSpellChecker *
 gtk_spell_checker_new_for_languages (const char * const * languages)
 {
-  return g_object_new (GTK_TYPE_SPELL_CHECKER,
-                       "languages", languages,
-                       NULL);
+  GtkSpellChecker *ret;
+
+  ret = g_object_new (GTK_TYPE_SPELL_CHECKER,
+                      "languages", languages,
+                      NULL);
+
+  if (ret != NULL && ret->languages->len == 0)
+    g_clear_object (&ret);
+
+  return g_steal_pointer (&ret);
 }
 
 const char * const *


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