From dacd8088a4b7c141baa28d454dd28e62b5fea0bc Mon Sep 17 00:00:00 2001 From: songwentao Date: Thu, 22 Sep 2022 02:11:33 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BD=95=E5=B1=8F?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E6=B2=A1=E6=9C=89=E6=98=BE=E7=A4=BA=E5=9C=A8?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E5=99=A8=E4=B8=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit systemd拉起deepin-application-manager进程时,系统环境变量XDG_CURRENT_DESKTOP键值为空,而录屏应用只显示在Deepin系统环境中 修复方法:在XDG_CURRENT_DESKTOP赋值后再拉起deepin-application-manager. Log: Influence: 修改AM 启动时序,确保系统环境变量已装载完成再启动 Bug: https://pms.uniontech.com/bug-view-159147.html Change-Id: I39301ff52d54d53131890c847e418799a91b83b8 --- misc/service/dde-application-manager.service | 6 ++++ src/lib/desktopinfo.cpp | 38 ++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/misc/service/dde-application-manager.service b/misc/service/dde-application-manager.service index f97c8bc..cd02394 100644 --- a/misc/service/dde-application-manager.service +++ b/misc/service/dde-application-manager.service @@ -8,6 +8,12 @@ CollectMode=inactive-or-failed StartLimitIntervalSec=10s StartLimitBurst=30 +Requisite=dde-session-manager.target +After=dde-session-manager.target + +Requisite=dde-display.target +After=dde-display.target + BindsTo=dde-session-daemon.service Before=dde-session-daemon.service diff --git a/src/lib/desktopinfo.cpp b/src/lib/desktopinfo.cpp index cd473db..ea60181 100644 --- a/src/lib/desktopinfo.cpp +++ b/src/lib/desktopinfo.cpp @@ -26,6 +26,8 @@ #include "dfile.h" #include "basedir.h" +#include + #include #include #include @@ -96,10 +98,16 @@ bool DesktopInfo::isValidDesktop() return m_isValid; } +/** if return true, item is shown + * @brief DesktopInfo::shouldShow + * @return + */ bool DesktopInfo::shouldShow() { - if (getNoDisplay() || getIsHidden()) + if (getNoDisplay() || getIsHidden()) { + qDebug() << "hidden desktop file path: " << QString::fromStdString(m_fileName); return false; + } std::vector desktopEnvs; return getShowIn(desktopEnvs); @@ -117,6 +125,10 @@ bool DesktopInfo::getIsHidden() bool DesktopInfo::getShowIn(std::vector desktopEnvs) { +#ifdef QT_DEBUG + qDebug() << "desktop file path: " << QString::fromStdString(m_fileName); +#endif + if (desktopEnvs.size() == 0) { const char *env = getenv(envDesktopEnv.c_str()); const auto &desktop = DString::splitChars(env, ':'); @@ -127,14 +139,34 @@ bool DesktopInfo::getShowIn(std::vector desktopEnvs) std::vector onlyShowIn = m_keyFile.getStrList(MainSection, KeyOnlyShowIn); std::vector notShowIn = m_keyFile.getStrList(MainSection, KeyNotShowIn); +#ifdef QT_DEBUG + auto strVector2qstrVector = [](const std::vector &vector) { + QVector vectorString; + for (const std::string &str : vector) + vectorString.append(QString::fromStdString(str)); + + return vectorString; + }; + + qDebug() << "onlyShowIn:" << strVector2qstrVector(onlyShowIn) << + ", notShowIn:" << strVector2qstrVector(notShowIn) << + ", desktopEnvs:" << strVector2qstrVector(desktopEnvs); +#endif + for (const auto &desktop : desktopEnvs) { bool ret = std::any_of(onlyShowIn.begin(), onlyShowIn.end(), [&desktop](const auto &d) {return d == desktop;}); +#ifdef QT_DEBUG + qInfo() << Q_FUNC_INFO << "onlyShowIn, result:" << ret; +#endif if (ret) return true; ret = std::any_of(notShowIn.begin(), notShowIn.end(), [&desktop](const auto &d) {return d == desktop;}); +#ifdef QT_DEBUG + qInfo() << Q_FUNC_INFO << "notShowIn, result:" << ret; +#endif if (ret) return false; } @@ -383,8 +415,10 @@ std::vector AppsDir::getAllDesktopInfos() std::string filePath = dir + iter.first; DesktopInfo desktopInfo(filePath); - if (!DFile::isExisted(filePath) || !desktopInfo.isValidDesktop() || !desktopInfo.shouldShow()) + if (!DFile::isExisted(filePath) || !desktopInfo.isValidDesktop() || !desktopInfo.shouldShow()) { + qDebug() << QString("app item %1 doesn't show in the list..").arg(QString::fromStdString(filePath)); continue; + } desktopInfos.push_back(desktopInfo); }