Skip to content

Commit 0093efa

Browse files
committed
fix(dbus): pass isNewLaunch flag to fix LastLaunchedTime stats
sender() always returns nullptr when called across QObject boundaries. handleUnitStarted on ApplicationService was using sender() to determine launch tracking, causing LastLaunchedTime/LaunchedTimes to never be updated. Use an explicit bool parameter instead. handleUnitStarted 在 ApplicationService 上通过 sender() 判断是否为新启动,但跨 QObject 调用时 sender() 始终为 nullptr,导致 LastLaunchedTime/LaunchedTimes 无法更新。 改为显式传递 bool 参数。 Log: 修复跨 QObject 调用时 sender() 失效导致启动统计不更新 Influence: 修复后 LastLaunchedTime 和 LaunchedTimes 能正确记录每次应用的启动时间与次数。 PMS: TASK-389405
1 parent 14618d4 commit 0093efa

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/dbus/applicationmanager1service.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ void ApplicationManager1Service::onUnitNew(const QString &unitName,
402402
instanceId = QUuid::createUuid().toString(QUuid::Id128);
403403
}
404404

405-
app->handleUnitStarted(instanceId, systemdUnitPath.path(), info->launcher, {});
405+
app->handleUnitStarted(instanceId, systemdUnitPath.path(), info->launcher, {}, sender() != nullptr);
406406
}
407407

408408
void ApplicationManager1Service::onUnitRemoved(const QString &unitName,

src/dbus/applicationservice.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,11 +1144,12 @@ void ApplicationService::removeAllInstance() noexcept
11441144
void ApplicationService::handleUnitStarted(const QString &instanceId,
11451145
const QString &systemdUnitPath,
11461146
const QString &launcher,
1147-
const QString &launchType) noexcept
1147+
const QString &launchType,
1148+
bool isNewLaunch) noexcept
11481149
{
11491150
using namespace Qt::StringLiterals;
11501151

1151-
updateAfterLaunch(sender() != nullptr);
1152+
updateAfterLaunch(isNewLaunch);
11521153

11531154
auto lt = launchType;
11541155
if (lt.isEmpty()) {

src/dbus/applicationservice.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ class ApplicationService : public QObject, protected QDBusContext
139139
void handleUnitStarted(const QString &instanceId,
140140
const QString &systemdUnitPath,
141141
const QString &launcher,
142-
const QString &launchType) noexcept;
142+
const QString &launchType,
143+
bool isNewLaunch) noexcept;
143144
void handleUnitRemoved(const QString &systemdUnitPath, const QString &unitName) noexcept;
144145
void recoverInstances(const QList<QDBusObjectPath> &instanceList) noexcept;
145146
void removeOneInstance(const QDBusObjectPath &instance) noexcept;

0 commit comments

Comments
 (0)