From 95d6bceb9b307a6c3ba1935f6cbdb708da170ca1 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 18 Oct 2019 11:47:02 +0300 Subject: [PATCH] Layout stops after timeout too slow. --HG-- branch : develop --- src/libs/vlayout/vlayoutgenerator.cpp | 36 +++++++++++++++------------ 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/libs/vlayout/vlayoutgenerator.cpp b/src/libs/vlayout/vlayoutgenerator.cpp index c7e113c6b..faf6158dc 100644 --- a/src/libs/vlayout/vlayoutgenerator.cpp +++ b/src/libs/vlayout/vlayoutgenerator.cpp @@ -103,7 +103,26 @@ int VLayoutGenerator::DetailsCount() //--------------------------------------------------------------------------------------------------------------------- void VLayoutGenerator::Generate(const QElapsedTimer &timer, qint64 timeout, LayoutErrors previousState) { - stopGeneration.store(false); + 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(); } //---------------------------------------------------------------------------------------------------------------------