Fix GUI freezing while nesting.

This commit is contained in:
Roman Telezhynskyi 2023-09-03 13:52:03 +03:00
parent a33ad45e37
commit 812c0b84d7
4 changed files with 23 additions and 29 deletions

View File

@ -37,6 +37,7 @@
- Support for Dark mode.
- Fix issue with passing incorrect number of dimension to Tape.
- New option: Pointer mode.
- Fix GUI freezing while nesting.
# Valentina 0.7.52 September 12, 2022
- Fix crash when default locale is ru.

View File

@ -278,7 +278,15 @@ auto MainWindowsNoGUI::GenerateLayout(VLayoutGenerator &lGenerator) -> bool
break;
}
lGenerator.Generate(timer, lGenerator.GetNestingTimeMSecs(), nestingState);
{
QEventLoop wait;
QFutureWatcher<void> fw;
fw.setFuture(
QtConcurrent::run([&lGenerator, timer, nestingState]()
{ lGenerator.Generate(timer, lGenerator.GetNestingTimeMSecs(), nestingState); }));
QObject::connect(&fw, &QFutureWatcher<void>::finished, &wait, &QEventLoop::quit);
wait.exec();
}
if (IsTimeout())
{
@ -380,12 +388,14 @@ auto MainWindowsNoGUI::GenerateLayout(VLayoutGenerator &lGenerator) -> bool
break;
}
nestingState = lGenerator.State();
if (nestingState == LayoutErrors::PrepareLayoutError || nestingState == LayoutErrors::ProcessStoped ||
nestingState == LayoutErrors::TerminatedByException ||
(nestingState == LayoutErrors::NoError && not qFuzzyIsNull(lGenerator.GetEfficiencyCoefficient()) &&
efficiency >= lGenerator.GetEfficiencyCoefficient()))
nestingState == LayoutErrors::TerminatedByException)
{
break;
}
if (nestingState == LayoutErrors::NoError && not qFuzzyIsNull(lGenerator.GetEfficiencyCoefficient()) &&
efficiency >= lGenerator.GetEfficiencyCoefficient())
{
if (not lGenerator.IsPreferOneSheetSolution() || lGenerator.PapersCount() == 1)
{

View File

@ -214,8 +214,6 @@ void VLayoutGenerator::Generate(const QElapsedTimer &timer, qint64 timeout, Layo
return;
}
QCoreApplication::processEvents();
if (stopGeneration.load())
{
break;

View File

@ -238,27 +238,12 @@ auto VPosition::ArrangeDetail(const VPositionData &data, std::atomic_bool *stop,
watcher.setFuture(QtConcurrent::mapped(jobs, Nest));
while (not watcher.isStarted())
{
QCoreApplication::processEvents();
QThread::msleep(250);
}
// Wait for done
do
{
QCoreApplication::processEvents();
QThread::msleep(250);
} while (watcher.isRunning() && not stop->load());
QEventLoop wait;
QObject::connect(&watcher, &QFutureWatcher<VBestSquare>::finished, &wait, &QEventLoop::quit);
wait.exec();
if (stop->load())
{
do
{
QCoreApplication::processEvents();
QThread::msleep(250);
} while (watcher.isRunning());
return bestResult;
}