From 0fab029faaa06335b5c208b6108b7a05104e8b6d Mon Sep 17 00:00:00 2001 From: Rajeev Ranjan Date: Sat, 15 Oct 2011 14:13:50 +0530 Subject: [PATCH] [prevent issues ID:55300,38821,19282,55298 for test_fileselector.c and elc_fileselector.c] Change-Id: I761f66d7dba4f22ab201e0fc4fba633cb4077682 --- src/bin/test_fileselector.c | 5 ++++- src/lib/elc_fileselector.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/bin/test_fileselector.c b/src/bin/test_fileselector.c index ba7b54c..2057fc5 100644 --- a/src/bin/test_fileselector.c +++ b/src/bin/test_fileselector.c @@ -108,6 +108,7 @@ test_fileselector(void *data __UNUSED__, void *event_info __UNUSED__) { Evas_Object *win, *fs, *bg, *vbox, *hbox, *bt, *sep; + const char *path = NULL; /* Set the locale according to the system pref. * If you dont do so the file selector will order the files list in @@ -137,7 +138,9 @@ test_fileselector(void *data __UNUSED__, /* make the file list a tree with dir expandable in place */ elm_fileselector_expandable_set(fs, EINA_FALSE); /* start the fileselector in the home dir */ - elm_fileselector_path_set(fs, getenv("HOME")); + path = getenv("HOME"); + if (!path) path = "./"; + elm_fileselector_path_set(fs, path); /* allow fs to expand in x & y */ evas_object_size_hint_weight_set(fs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(fs, EVAS_HINT_FILL, EVAS_HINT_FILL); diff --git a/src/lib/elc_fileselector.c b/src/lib/elc_fileselector.c index 9d6e1a3..57c78dd 100644 --- a/src/lib/elc_fileselector.c +++ b/src/lib/elc_fileselector.c @@ -476,7 +476,10 @@ _home(void *data, void *event_info __UNUSED__) { Evas_Object *fs = data; - _populate(fs, getenv("HOME"), NULL); + const char *path = getenv("HOME"); + if (!path) path = "./"; + _populate(fs, path, NULL); + } static void @@ -1128,12 +1131,14 @@ elm_fileselector_selected_get(const Evas_Object *obj) { const char *name; char buf[PATH_MAX]; + char *dir; + dir = wd->only_folder ? ecore_file_dir_get(wd->path) : strdup(wd->path); name = elm_entry_entry_get(wd->filename_entry); snprintf(buf, sizeof(buf), "%s/%s", - wd->only_folder ? ecore_file_dir_get(wd->path) : wd->path, - name); + dir, name); eina_stringshare_replace(&wd->selection, buf); + if (dir) free(dir); return wd->selection; } -- 2.7.4