From a265d98a59ab08e2c5bca257ae5a85258712cfcd Mon Sep 17 00:00:00 2001 From: woblight Date: Sat, 11 Jan 2020 12:19:08 +0100 Subject: [PATCH] Restore repair repository function --- AddonsPanel.qml | 3 ++- addon.cpp | 22 ++++++++++++++++------ addon.h | 3 +++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/AddonsPanel.qml b/AddonsPanel.qml index d424394..4c225b4 100644 --- a/AddonsPanel.qml +++ b/AddonsPanel.qml @@ -150,7 +150,6 @@ Page { } MenuItem { - enabled: addon.status == Addon.Status.Ready id: repairButton hoverEnabled: true state: addon.gitStatus === Addon.Error ? "reclone" : "reset" @@ -158,6 +157,7 @@ Page { State { name: "reset" PropertyChanges { + enabled: addon.status == Addon.Status.Ready target: repairButton text: qsTr("repair") icon.name: "document-edit-decrypt" @@ -169,6 +169,7 @@ Page { State { name: "reclone" PropertyChanges { + enabled: true target: repairButton text: qsTr("repair repository") icon.name: "view-refresh" diff --git a/addon.cpp b/addon.cpp index 81eeb59..a7294fc 100644 --- a/addon.cpp +++ b/addon.cpp @@ -536,7 +536,7 @@ void Addon::reclone() update(); scanBranches(); } - }); + }, true); } void Addon::loadReadme() @@ -665,10 +665,10 @@ AutoPtr Addon::branchRef(QString name) return lbr; } -void Addon::delegate(QString taskname, auto work, auto callback) +void Addon::delegate(QString taskname, auto work, auto callback, bool force) { Q_ASSERT_X(QThread::currentThread() == thread(), "delegate", "Attempt to delegate from another thread."); - if (status() != Status::Ready) { + if (status() != Status::Ready && !force) { qInfo() << name() << "Enqueueing" << taskname; m_tasks.enqueue({taskname, [this, taskname, work, callback](){delegate(taskname, work,callback);}}); return; @@ -709,11 +709,21 @@ void Addon::delegate(QString taskname, auto work, auto callback) fw->setFuture(fut); } -void Addon::delegate(QString taskname, auto work) +void Addon::delegate(QString taskname, auto work, bool force) { using ret_t = typename std::invoke_result::type; if constexpr (std::is_same::value) - delegate(taskname, work, [](){}); + delegate(taskname, work, [](){}, force); else - delegate(taskname, work, [](ret_t){}); + delegate(taskname, work, [](ret_t){}, force); +} + +void Addon::delegate(QString taskname, auto work) +{ + delegate(taskname, work, false); +} + +void Addon::delegate(QString taskname, auto work, auto callback) +{ + delegate(taskname, work, callback, false); } diff --git a/addon.h b/addon.h index a29c2a7..09b510a 100644 --- a/addon.h +++ b/addon.h @@ -138,6 +138,9 @@ private: AutoPtr remoteRefForBranch(QString name); AutoPtr branchRef(QString name); + void delegate(QString taskname, auto work, auto callback, bool force); + void delegate(QString taskname, auto work, bool force); + void delegate(QString taskname, auto work, auto callback); void delegate(QString taskname, auto work);