Layout stops after timeout too slow.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-10-18 11:47:02 +03:00
parent ea75af2f46
commit 95d6bceb9b

View File

@ -102,8 +102,27 @@ int VLayoutGenerator::DetailsCount()
//---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::Generate(const QElapsedTimer &timer, qint64 timeout, LayoutErrors previousState)
{
auto HasExpired = [this, timer, timeout]()
{
if (timer.hasExpired(timeout))
{
Timeout();
return true;
}
return false;
};
if (HasExpired())
{
return;
}
if (state != LayoutErrors::Timeout)
{
stopGeneration.store(false);
}
papers.clear();
bank->Reset();
state = previousState;
@ -111,19 +130,6 @@ void VLayoutGenerator::Generate(const QElapsedTimer &timer, qint64 timeout, Layo
int width = PageWidth();
int height = PageHeight();
auto HasExpired = [this, timer, timeout]()
{
if (timer.hasExpired(timeout))
{
if (state == LayoutErrors::NoError)
{
state = LayoutErrors::Timeout;
}
return true;
}
return false;
};
if (VFuzzyComparePossibleNulls(shift, -1))
{
if (bank->PrepareDetails())
@ -333,7 +339,6 @@ void VLayoutGenerator::Abort()
{
stopGeneration.store(true);
state = LayoutErrors::ProcessStoped;
QThreadPool::globalInstance()->clear();
}
//---------------------------------------------------------------------------------------------------------------------
@ -344,7 +349,6 @@ void VLayoutGenerator::Timeout()
{
state = LayoutErrors::Timeout;
}
QThreadPool::globalInstance()->clear();
}
//---------------------------------------------------------------------------------------------------------------------