diff options
author | Julian Eisel <julian@blender.org> | 2020-12-16 22:28:15 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-12-16 22:36:37 +0300 |
commit | 9d152263837f0ac5e790e0b12d3b3cfed31bed0f (patch) | |
tree | 4914ccf58b3599f5469c524d1bf93299fa08249c /intern | |
parent | a8da70f70a1f581412982d1f858b7b9a96ab8c37 (diff) |
Ghost/Linux: Avoid error print if special directory can't be determined
The function is supposed to fail gracefully if there is some error. That
includes not being able to find `xdg-user-dir`. So don't let the error
be printed to the console, it's misleading/annoying.
From what I can tell we'll detect that problem fine and return NULL
then.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/intern/GHOST_SystemPathsUnix.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/intern/ghost/intern/GHOST_SystemPathsUnix.cpp b/intern/ghost/intern/GHOST_SystemPathsUnix.cpp index fdfde13b915..86f3a0a31fb 100644 --- a/intern/ghost/intern/GHOST_SystemPathsUnix.cpp +++ b/intern/ghost/intern/GHOST_SystemPathsUnix.cpp @@ -142,7 +142,8 @@ const GHOST_TUns8 *GHOST_SystemPathsUnix::getUserSpecialDir(GHOST_TUserSpecialDi } static string path = ""; - string command = string("xdg-user-dir ") + type_str; + /* Pipe stderr to /dev/null to avoid error prints. We will fail gracefully still. */ + string command = string("xdg-user-dir ") + type_str + " 2> /dev/null"; FILE *fstream = popen(command.c_str(), "r"); if (fstream == NULL) { @@ -163,7 +164,7 @@ const GHOST_TUns8 *GHOST_SystemPathsUnix::getUserSpecialDir(GHOST_TUserSpecialDi } path = path_stream.str(); - return (const GHOST_TUns8 *)path.c_str(); + return path[0] ? (const GHOST_TUns8 *)path.c_str() : NULL; } const GHOST_TUns8 *GHOST_SystemPathsUnix::getBinaryDir() const |