refact: assuming all applications have been launched during AM create
storage at first time issue: https://github.com/linuxdeepin/developer-center/issues/5768 Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
@ -84,6 +84,9 @@ void ApplicationManager1Service::initService(QDBusConnection &connection) noexce
|
||||
|
||||
scanInstances();
|
||||
|
||||
auto storagePtr = m_storage.lock();
|
||||
storagePtr->setFirstLaunch(false);
|
||||
|
||||
loadHooks();
|
||||
|
||||
if (auto *ptr = new (std::nothrow) PropertiesForwarder{DDEApplicationManager1ObjectPath, this}; ptr == nullptr) {
|
||||
|
@ -47,14 +47,21 @@ ApplicationService::ApplicationService(DesktopFile source,
|
||||
|
||||
auto appId = id();
|
||||
auto value = storagePtr->readApplicationValue(appId, ApplicationPropertiesGroup, LastLaunchedTime);
|
||||
if (value.isNull()) {
|
||||
if (!storagePtr->createApplicationValue(
|
||||
appId, ApplicationPropertiesGroup, LastLaunchedTime, QVariant::fromValue<qint64>(0))) {
|
||||
m_lastLaunch = -1;
|
||||
}
|
||||
return;
|
||||
|
||||
qint64 val{0};
|
||||
if (storagePtr->firstLaunch()) {
|
||||
val = QDateTime::currentMSecsSinceEpoch();
|
||||
}
|
||||
|
||||
if (value.isNull()) {
|
||||
if (!storagePtr->createApplicationValue(appId, ApplicationPropertiesGroup, LastLaunchedTime, QVariant::fromValue(val))) {
|
||||
m_lastLaunch = -1;
|
||||
} else {
|
||||
m_lastLaunch = val;
|
||||
}
|
||||
} else {
|
||||
m_lastLaunch = value.toLongLong();
|
||||
}
|
||||
m_lastLaunch = value.toInt();
|
||||
|
||||
value = storagePtr->readApplicationValue(appId, ApplicationPropertiesGroup, ScaleFactor);
|
||||
if (!value.isNull()) {
|
||||
|
Reference in New Issue
Block a user