refact: remove static env instance
Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
parent
d00cd17f2e
commit
f2d5b7b307
@ -366,7 +366,6 @@ inline QString getRelativePathFromAppId(const QString &id)
|
||||
|
||||
inline QStringList getDesktopFileDirs()
|
||||
{
|
||||
const static auto XDGDataDirs = []() {
|
||||
auto XDGDataDirs = QString::fromLocal8Bit(qgetenv("XDG_DATA_DIRS")).split(':', Qt::SkipEmptyParts);
|
||||
|
||||
if (XDGDataDirs.isEmpty()) {
|
||||
@ -388,15 +387,11 @@ inline QStringList getDesktopFileDirs()
|
||||
str.append("applications");
|
||||
});
|
||||
|
||||
return XDGDataDirs;
|
||||
}();
|
||||
|
||||
return XDGDataDirs;
|
||||
}
|
||||
|
||||
inline QStringList getAutoStartDirs()
|
||||
{
|
||||
const static auto XDGConfigDirs = []() {
|
||||
auto XDGConfigDirs = QString::fromLocal8Bit(qgetenv("XDG_CONFIG_DIRS")).split(':', Qt::SkipEmptyParts);
|
||||
if (XDGConfigDirs.isEmpty()) {
|
||||
XDGConfigDirs.append("/etc/xdg");
|
||||
@ -416,9 +411,6 @@ inline QStringList getAutoStartDirs()
|
||||
str.append("autostart");
|
||||
});
|
||||
|
||||
return XDGConfigDirs;
|
||||
}();
|
||||
|
||||
return XDGConfigDirs;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
env = qgetenv("XDG_DATA_DIRS");
|
||||
auto curDir = QDir::current();
|
||||
QByteArray fakeXDG = (curDir.absolutePath() + QDir::separator() + "data").toLocal8Bit();
|
||||
qputenv("XDG_DATA_DIRS", fakeXDG);
|
||||
ASSERT_TRUE(qputenv("XDG_DATA_DIRS", fakeXDG)) ;
|
||||
DesktopErrorCode err;
|
||||
auto file = DesktopFile::searchDesktopFileById("deepin-editor", err);
|
||||
if (!file.has_value()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user