[gnome-text-editor] sidebar: special case uri of /



commit 01b869df207e92b8b7c634b107e8c1daa43a20e0
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jan 10 15:09:01 2022 -0800

    sidebar: special case uri of /

 src/editor-sidebar-item.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/src/editor-sidebar-item.c b/src/editor-sidebar-item.c
index d84e2b2..8d449b5 100644
--- a/src/editor-sidebar-item.c
+++ b/src/editor-sidebar-item.c
@@ -80,14 +80,13 @@ editor_sidebar_item_update_subtitle (EditorSidebarItem *self)
       return;
     }
 
-  dir = g_file_get_parent (self->file);
-  if (g_file_is_native (dir))
-    {
-      self->subtitle = _editor_path_collapse (g_file_peek_path (dir));
-      return;
-    }
-
-  self->subtitle = g_file_get_uri (dir);
+  /* Can happen, but implausible since someone tried to open "/" */
+  if (!(dir = g_file_get_parent (self->file)))
+    self->subtitle = g_strdup ("");
+  else if (g_file_is_native (dir))
+    self->subtitle = _editor_path_collapse (g_file_peek_path (dir));
+  else
+    self->subtitle = g_file_get_uri (dir);
 }
 
 static void


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