diff --git a/ChangeLog b/ChangeLog index 5f988723f5..5cac1e9f58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-08-14 Tor Lillqvist + + * gtk/gtkfilechooserdefault.c (shortcuts_append_home, + shortcuts_append_desktop, set_local_only) + * gtk/gtkfilesystemwin32.c (gtk_file_system_win32_render_icon) + * gtk/gtkpathbar.c (find_button_type, _gtk_path_bar_set_file_system): + Guard against g_get_home_dir() returning NULL. (#150007) + Sat Aug 14 17:56:33 2004 Soeren Sandmann * gtk/gtkentry.c (gtk_entry_get_pixel_ranges): New function. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 5f988723f5..5cac1e9f58 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +2004-08-14 Tor Lillqvist + + * gtk/gtkfilechooserdefault.c (shortcuts_append_home, + shortcuts_append_desktop, set_local_only) + * gtk/gtkfilesystemwin32.c (gtk_file_system_win32_render_icon) + * gtk/gtkpathbar.c (find_button_type, _gtk_path_bar_set_file_system): + Guard against g_get_home_dir() returning NULL. (#150007) + Sat Aug 14 17:56:33 2004 Soeren Sandmann * gtk/gtkentry.c (gtk_entry_get_pixel_ranges): New function. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 5f988723f5..5cac1e9f58 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +2004-08-14 Tor Lillqvist + + * gtk/gtkfilechooserdefault.c (shortcuts_append_home, + shortcuts_append_desktop, set_local_only) + * gtk/gtkfilesystemwin32.c (gtk_file_system_win32_render_icon) + * gtk/gtkpathbar.c (find_button_type, _gtk_path_bar_set_file_system): + Guard against g_get_home_dir() returning NULL. (#150007) + Sat Aug 14 17:56:33 2004 Soeren Sandmann * gtk/gtkentry.c (gtk_entry_get_pixel_ranges): New function. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 5f988723f5..5cac1e9f58 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +2004-08-14 Tor Lillqvist + + * gtk/gtkfilechooserdefault.c (shortcuts_append_home, + shortcuts_append_desktop, set_local_only) + * gtk/gtkfilesystemwin32.c (gtk_file_system_win32_render_icon) + * gtk/gtkpathbar.c (find_button_type, _gtk_path_bar_set_file_system): + Guard against g_get_home_dir() returning NULL. (#150007) + Sat Aug 14 17:56:33 2004 Soeren Sandmann * gtk/gtkentry.c (gtk_entry_get_pixel_ranges): New function. diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index bdb7e84f6d..f0a9225410 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -1079,6 +1079,9 @@ shortcuts_append_home (GtkFileChooserDefault *impl) GError *error; home = g_get_home_dir (); + if (home == NULL) + return; + home_path = gtk_file_system_filename_to_path (impl->file_system, home); error = NULL; @@ -1093,10 +1096,15 @@ shortcuts_append_home (GtkFileChooserDefault *impl) static void shortcuts_append_desktop (GtkFileChooserDefault *impl) { + const char *home; char *name; GtkFilePath *path; - name = g_build_filename (g_get_home_dir (), "Desktop", NULL); + home = g_get_home_dir (); + if (home == NULL) + return; + + name = g_build_filename (home, "Desktop", NULL); path = gtk_file_system_filename_to_path (impl->file_system, name); g_free (name); @@ -3318,7 +3326,12 @@ set_local_only (GtkFileChooserDefault *impl, * such a situation, so we ignore errors. */ const gchar *home = g_get_home_dir (); - GtkFilePath *home_path = gtk_file_system_filename_to_path (impl->file_system, home); + GtkFilePath *home_path; + + if (home == NULL) + return; + + home_path = gtk_file_system_filename_to_path (impl->file_system, home); _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), home_path, NULL); diff --git a/gtk/gtkfilesystemwin32.c b/gtk/gtkfilesystemwin32.c index 9c72f208fe..fd68a339ab 100644 --- a/gtk/gtkfilesystemwin32.c +++ b/gtk/gtkfilesystemwin32.c @@ -1101,7 +1101,8 @@ gtk_file_system_win32_render_icon (GtkFileSystem *file_system, } else if (g_file_test (filename, G_FILE_TEST_IS_DIR)) { - if (0 == strcmp (g_get_home_dir(), filename)) + const gchar *home = g_get_home_dir (); + if (home != NULL && 0 == strcmp (home, filename)) icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_HOME); else icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_DIRECTORY); diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c index e3cbe7d580..bd8516f611 100644 --- a/gtk/gtkpathbar.c +++ b/gtk/gtkpathbar.c @@ -916,11 +916,14 @@ static ButtonType find_button_type (GtkPathBar *path_bar, GtkFilePath *path) { - if (! gtk_file_path_compare (path, path_bar->root_path)) + if (path_bar->root_path != NULL && + ! gtk_file_path_compare (path, path_bar->root_path)) return ROOT_BUTTON; - if (! gtk_file_path_compare (path, path_bar->home_path)) + if (path_bar->home_path != NULL && + ! gtk_file_path_compare (path, path_bar->home_path)) return HOME_BUTTON; - if (! gtk_file_path_compare (path, path_bar->desktop_path)) + if (path_bar->desktop_path != NULL && + ! gtk_file_path_compare (path, path_bar->desktop_path)) return DESKTOP_BUTTON; return NORMAL_BUTTON; @@ -1170,11 +1173,22 @@ _gtk_path_bar_set_file_system (GtkPathBar *path_bar, path_bar->file_system = g_object_ref (file_system); home = g_get_home_dir (); - desktop = g_build_filename (home, "Desktop", NULL); - path_bar->home_path = gtk_file_system_filename_to_path (path_bar->file_system, home); - path_bar->desktop_path = gtk_file_system_filename_to_path (path_bar->file_system, desktop); + if (home != NULL) + { + path_bar->home_path = gtk_file_system_filename_to_path (path_bar->file_system, home); + /* FIXME: Need file system backend specific way of getting the + * Desktop path. + */ + desktop = g_build_filename (home, "Desktop", NULL); + path_bar->desktop_path = gtk_file_system_filename_to_path (path_bar->file_system, desktop); + g_free (desktop); + } + else + { + path_bar->home_path = NULL; + path_bar->desktop_path = NULL; + } path_bar->root_path = gtk_file_system_filename_to_path (path_bar->file_system, "/"); - g_free (desktop); } /**