diff --git a/src/FactorizationController.cpp b/src/FactorizationController.cpp index 1300f19..dc9cf79 100644 --- a/src/FactorizationController.cpp +++ b/src/FactorizationController.cpp @@ -58,7 +58,17 @@ void FactorizationController::setUseSqrtOptimization(bool value) { m_useSqrtOptimization = value; emit useSqrtOptimizationChanged(); - reset(); + + // We're in a reset state + if (m_originalNumber == 0) + return; + + if (m_useSqrtOptimization) + m_stopFactor = static_cast(std::sqrt(m_currentFactNumber)); + else + m_stopFactor = m_currentFactNumber - 1; + emit stopFactorChanged(); + emit progressChanged(); } bool FactorizationController::pauseOnFound() const { diff --git a/src/FactorizationController.h b/src/FactorizationController.h index a2f3835..af4d3e9 100644 --- a/src/FactorizationController.h +++ b/src/FactorizationController.h @@ -167,8 +167,10 @@ class FactorizationController : public QObject { * Generally, there's no reason to disable this optimization, however, if you wish to * perform a slower search, it is a way to achieve that. * - * Note that changing this value while the computation is in progress will reset the - * computation. + * This value can be changed even as a computation is ongoing; if you do so, the stop factor + * will change immediately, which will very likely cause the progress bar to rapidly change. + * It is possible that after enabling, the computation will immediately finish, as the stop + * factor will be less than the sqrt(x). */ void setUseSqrtOptimization(bool value);