From fa98e47d6319d473e756ab14fd80fbf87d95d46f Mon Sep 17 00:00:00 2001 From: manongjohn Date: Sep 10 2019 19:44:21 +0000 Subject: Merge pull request #2756 from martinvanzijl/use-qt-homedir-instead-of-getenv Use QDir::home() instead of getenv("HOME") in file browser --- diff --git a/toonz/sources/toonz/filebrowsermodel.cpp b/toonz/sources/toonz/filebrowsermodel.cpp index dc6f523..7b6bd1f 100644 --- a/toonz/sources/toonz/filebrowsermodel.cpp +++ b/toonz/sources/toonz/filebrowsermodel.cpp @@ -51,13 +51,9 @@ TFilePath getMyDocumentsPath() { return TFilePath((const char *)[documentsDirectory cStringUsingEncoding:NSASCIIStringEncoding]); #else - std::string path(getenv("HOME")); - if(path.empty()) return TFilePath(); - path += "/Documents"; - QString pathAsQString = QString::fromStdString(path); - QDir dir(pathAsQString); - if(!dir.exists()) return TFilePath(); - return TFilePath(path); + QDir dir = QDir::home(); + if (!dir.cd("Documents")) return TFilePath(); + return TFilePath(dir.absolutePath().toStdString()); #endif } @@ -79,13 +75,9 @@ TFilePath getDesktopPath() { return TFilePath((const char *)[desktopDirectory cStringUsingEncoding:NSASCIIStringEncoding]); #else - std::string path(getenv("HOME")); - if(path.empty()) return TFilePath(); - path += "/Desktop"; - QString pathAsQString = QString::fromStdString(path); - QDir dir(pathAsQString); - if(!dir.exists()) return TFilePath(); - return TFilePath(path); + QDir dir = QDir::home(); + if (!dir.cd("Desktop")) return TFilePath(); + return TFilePath(dir.absolutePath().toStdString()); #endif } }