Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dcc-update-plugin/operation/updatemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ UpdateModel::UpdateModel(QObject* parent)
: QObject(parent)
, m_lastoreDaemonStatus(0)
, m_isUpdateDisabled(false)
, m_systemActivation(false)
, m_systemActivation(true)
, m_batterIsOK(false)
, m_lastStatus(Default)
, m_showCheckUpdate(false)
Expand Down
11 changes: 11 additions & 0 deletions src/dcc-update-plugin/operation/updatework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ UpdateWorker::UpdateWorker(UpdateModel* model, QObject* parent)
, m_lastoreHeartBeatTimer(new QTimer(this))
, m_machineid(std::nullopt)
, m_testingChannelUrl(std::nullopt)
, m_doCheckUpdates(false)
, m_checkUpdateJob(nullptr)
, m_fixErrorJob(nullptr)
, m_downloadJob(nullptr)
Expand Down Expand Up @@ -381,6 +382,12 @@ void UpdateWorker::checkNeedDoUpdates()
return;
}

// 如果当前正在检查更新,则不再检查
if (m_doCheckUpdates) {
qCDebug(DCC_UPDATE_WORKER) << "Is doing check updates";
return;
}

// 如果打开控制中心后第一次进入检查更新界面,则显示页面并进行检查
static bool doCheckFirst = true;
if (doCheckFirst) {
Expand Down Expand Up @@ -432,6 +439,7 @@ void UpdateWorker::doCheckUpdates()

m_model->resetDownloadInfo(); // 在检查更新前重置数据,避免有上次检查的数据残留

m_doCheckUpdates = true;
QDBusPendingCall call = m_updateInter->UpdateSource();
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(call, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, watcher] {
Expand All @@ -440,6 +448,7 @@ void UpdateWorker::doCheckUpdates()
qCWarning(DCC_UPDATE_WORKER) << "Check update failed, error: " << reply.error().message();
m_model->setLastStatus(UpdatesStatus::CheckingFailed, __LINE__);
cleanLaStoreJob(m_checkUpdateJob);
m_doCheckUpdates = false;
} else {
const QString jobPath = reply.value().path();
qCInfo(DCC_UPDATE_WORKER) << "jobpath:" << jobPath;
Expand Down Expand Up @@ -1352,6 +1361,7 @@ void UpdateWorker::onCheckUpdateStatusChanged(const QString& value)
m_model->setLastStatus(CheckingFailed, __LINE__);
m_model->setCheckUpdateStatus(CheckingFailed);
deleteJob(m_checkUpdateJob);
m_doCheckUpdates = false;
}
} else if (value == "success" || value == "succeed") {
auto watcher = new QDBusPendingCallWatcher(m_updateInter->GetUpdateLogs(SystemUpdate | SecurityUpdate), this);
Expand All @@ -1374,6 +1384,7 @@ void UpdateWorker::onCheckUpdateStatusChanged(const QString& value)
m_model->setCheckUpdateStatus(UpdatesStatus(m_model->lastStatus()));
m_model->updateCheckUpdateUi();
deleteJob(m_checkUpdateJob);
m_doCheckUpdates = false;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/dcc-update-plugin/operation/updatework.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public Q_SLOTS:
std::optional<QUrl> m_testingChannelUrl;
QMutex m_downloadMutex;

bool m_doCheckUpdates;
QPointer<UpdateJobDBusProxy> m_checkUpdateJob;
QPointer<UpdateJobDBusProxy> m_fixErrorJob;
QPointer<UpdateJobDBusProxy> m_downloadJob;
Expand Down
21 changes: 21 additions & 0 deletions src/dcc-update-plugin/qml/update.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,31 @@ import org.deepin.dtk 1.0 as D
import org.deepin.dcc 1.0

DccObject {
id: root

property bool hasHandledChildrenChange: false
signal activeUpdateModel()

name: "update"
parentName: "root"
displayName: qsTr("System Update")
description: qsTr("System update and upgrade")
icon: "update"
weight: 100

page: DccRightView{

// 切换模块时候,控件会重新创建,从而触发检查更新
Component.onCompleted: {
activeUpdateModel();
}
}

// 通过dbus接口直接进入更新模块时,onCompleted已经发送了信号,但其子控件可能还没创建好,需要使用该信号触发检查更新,但只需要触发一次即可
onChildrenChanged : {
if (!hasHandledChildrenChange) {
hasHandledChildrenChange = true
activeUpdateModel();
}
}
}
8 changes: 3 additions & 5 deletions src/dcc-update-plugin/qml/updateMain.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ import org.deepin.dcc.update 1.0
DccObject {

Connections {
target: DccApp
function onActiveObjectChanged(obj) {
if (obj === dccModule) {
dccData.work().checkNeedDoUpdates()
}
target: dccModule
function onActiveUpdateModel() {
dccData.work().checkNeedDoUpdates()
}
}

Expand Down