From d7fcc9a0c79f186118e0c20804af1f7467fc4580 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale <0inkane@googlemail.com> Date: Thu, 29 Aug 2019 18:33:13 +0200 Subject: FcSolveSolver: cleanup ressources The FcSolveSolver did not call its free function in patsolve, leading to ressource exhaustion. BUG: 395624 --- patsolve/abstract_fc_solve_solver.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/patsolve/abstract_fc_solve_solver.cpp b/patsolve/abstract_fc_solve_solver.cpp index c82aee1..725c703 100644 --- a/patsolve/abstract_fc_solve_solver.cpp +++ b/patsolve/abstract_fc_solve_solver.cpp @@ -55,6 +55,16 @@ SolverInterface::ExitStatus FcSolveSolver::patsolve( int _max_positions ) init(); + // call free once the function ends. ### Replace this mess with QScopeGuard once we can use Qt 5.12 + auto cleanup = [this](){this->free();}; + using CleanupFunction = decltype (cleanup); + struct CleanupHandler { + CleanupHandler(CleanupFunction cleanup) : m_cleanup(std::move(cleanup)) {} + ~CleanupHandler() { m_cleanup();} + + CleanupFunction m_cleanup; + } cleaner(cleanup); + int no_use = 0; int num_moves = 0; const auto get_possible_moves__ret = get_possible_moves(&no_use, &num_moves); -- cgit v1.1