From 8e193b592ae06abb36be6f72ef43c308b511b24c Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 10 Jun 2019 11:02:03 -0300 Subject: [PATCH] Avoid refreshing the list of backup sessions when an item is doing some work/task --- src/app/ui/data_recovery_view.cpp | 27 +++++++++++++++++++++------ src/app/ui/data_recovery_view.h | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/app/ui/data_recovery_view.cpp b/src/app/ui/data_recovery_view.cpp index 27c7b1102..63cb530fd 100644 --- a/src/app/ui/data_recovery_view.cpp +++ b/src/app/ui/data_recovery_view.cpp @@ -258,6 +258,9 @@ DataRecoveryView::~DataRecoveryView() void DataRecoveryView::refreshListNotification() { + if (someItemIsBusy()) + return; + fillList(); layout(); } @@ -340,6 +343,19 @@ void DataRecoveryView::disableRefresh() m_waitToEnableRefreshTimer.start(); } +bool DataRecoveryView::someItemIsBusy() +{ + // Just in case check that we are not already running some task (so + // we cannot refresh the list) + for (auto widget : m_listBox.children()) { + if (auto item = dynamic_cast(widget)) { + if (item->isTaskRunning()) + return true; + } + } + return false; +} + std::string DataRecoveryView::getTabText() { return Strings::recover_files_title(); @@ -450,6 +466,9 @@ void DataRecoveryView::onDelete() void DataRecoveryView::onRefresh() { + if (someItemIsBusy()) + return; + m_dataRecovery->launchSearch(); fillList(); @@ -484,12 +503,8 @@ void DataRecoveryView::onChangeSelection() void DataRecoveryView::onCheckIfWeCanEnableRefreshButton() { - for (auto widget : m_listBox.children()) { - if (auto item = dynamic_cast(widget)) { - if (item->isTaskRunning()) - return; - } - } + if (someItemIsBusy()) + return; m_refreshButton.setEnabled(true); m_waitToEnableRefreshTimer.stop(); diff --git a/src/app/ui/data_recovery_view.h b/src/app/ui/data_recovery_view.h index fae5cf56a..c28c2ceb8 100644 --- a/src/app/ui/data_recovery_view.h +++ b/src/app/ui/data_recovery_view.h @@ -53,6 +53,7 @@ namespace app { void fillList(); void fillListWith(const bool crashes); void disableRefresh(); + bool someItemIsBusy(); void onOpen(); void onOpenRaw(crash::RawImagesAs as);