[gnome-control-center] network: Fix runtime warning



commit b7c4b30f635361c6f300323e72d65e7096ed9a68
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Jun 20 14:59:31 2017 +0200

    network: Fix runtime warning
    
    Create 2 veth interfaces without any names with, as root:
    ip link add veth0 type veth peer name veth1
    ip link set dev veth0 up
    ip link set dev veth1 up
    
    And run:
    (gnome-control-center:28176): GLib-CRITICAL **: g_utf8_collate: assertion 'str1 != NULL' failed
    (gnome-control-center:28176): GLib-CRITICAL **: g_utf8_collate: assertion 'str2 != NULL' failed
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783996

 panels/network/cc-network-panel.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index abc943e..7be3357 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -519,6 +519,7 @@ panel_net_object_sort_func (GtkTreeModel *model, GtkTreeIter *a,
         g_autoptr(NetObject) obj_a = NULL;
         g_autoptr(NetObject) obj_b = NULL;
         gint cat_a, cat_b;
+        const char *title_a, *title_b;
 
         gtk_tree_model_get (model, a,
                             PANEL_DEVICES_COLUMN_OBJECT, &obj_a,
@@ -533,7 +534,17 @@ panel_net_object_sort_func (GtkTreeModel *model, GtkTreeIter *a,
         if (cat_a != cat_b)
                 return cat_a - cat_b;
 
-        return g_utf8_collate (net_object_get_title (obj_a), net_object_get_title (obj_b));
+        title_a = net_object_get_title (obj_a);
+        title_b = net_object_get_title (obj_b);
+
+        if (title_a == title_b)
+                return 0;
+        if (title_a == NULL)
+                return -1;
+        if (title_b == NULL)
+                return 1;
+
+        return g_utf8_collate (title_a, title_b);
 }
 
 static void


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