From 1408f0cd0a2912b72839c46877d58e0a24f0240b Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 23 Jun 2016 11:25:54 +0200 Subject: [PATCH] + fix compiler warning + check for existence of directory before using it --- src/App/Application.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 351db5ea9..45a209a20 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -1910,12 +1910,14 @@ void Application::ExtractUserPath() throw Base::Exception("Getting HOME path from system failed!"); mConfig["UserHomePath"] = pwd->pw_dir; - char *path="/tmp"; - char *FCUserData; - if (FCUserData=getenv("FREECAD_USER_DATA")) - path = FCUserData; - else - path = pwd->pw_dir; + char *path = pwd->pw_dir; + char *fc_user_data; + if ((fc_user_data = getenv("FREECAD_USER_DATA"))) { + QString env = QString::fromUtf8(fc_user_data); + QDir dir(env); + if (!env.isEmpty() && dir.exists()) + path = fc_user_data; + } std::string appData(path); Base::FileInfo fi(appData.c_str());