Avoid refreshing the list of backup sessions when an item is doing some work/task

This commit is contained in:
David Capello 2019-06-10 11:02:03 -03:00
parent 07f64b7682
commit 8e193b592a
2 changed files with 22 additions and 6 deletions

View File

@ -258,6 +258,9 @@ DataRecoveryView::~DataRecoveryView()
void DataRecoveryView::refreshListNotification() void DataRecoveryView::refreshListNotification()
{ {
if (someItemIsBusy())
return;
fillList(); fillList();
layout(); layout();
} }
@ -340,6 +343,19 @@ void DataRecoveryView::disableRefresh()
m_waitToEnableRefreshTimer.start(); 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<Item*>(widget)) {
if (item->isTaskRunning())
return true;
}
}
return false;
}
std::string DataRecoveryView::getTabText() std::string DataRecoveryView::getTabText()
{ {
return Strings::recover_files_title(); return Strings::recover_files_title();
@ -450,6 +466,9 @@ void DataRecoveryView::onDelete()
void DataRecoveryView::onRefresh() void DataRecoveryView::onRefresh()
{ {
if (someItemIsBusy())
return;
m_dataRecovery->launchSearch(); m_dataRecovery->launchSearch();
fillList(); fillList();
@ -484,12 +503,8 @@ void DataRecoveryView::onChangeSelection()
void DataRecoveryView::onCheckIfWeCanEnableRefreshButton() void DataRecoveryView::onCheckIfWeCanEnableRefreshButton()
{ {
for (auto widget : m_listBox.children()) { if (someItemIsBusy())
if (auto item = dynamic_cast<Item*>(widget)) { return;
if (item->isTaskRunning())
return;
}
}
m_refreshButton.setEnabled(true); m_refreshButton.setEnabled(true);
m_waitToEnableRefreshTimer.stop(); m_waitToEnableRefreshTimer.stop();

View File

@ -53,6 +53,7 @@ namespace app {
void fillList(); void fillList();
void fillListWith(const bool crashes); void fillListWith(const bool crashes);
void disableRefresh(); void disableRefresh();
bool someItemIsBusy();
void onOpen(); void onOpen();
void onOpenRaw(crash::RawImagesAs as); void onOpenRaw(crash::RawImagesAs as);