diff --git a/routing/routes_builder/routes_builder.cpp b/routing/routes_builder/routes_builder.cpp index 8512d20c1f..798a8b1d3a 100644 --- a/routing/routes_builder/routes_builder.cpp +++ b/routing/routes_builder/routes_builder.cpp @@ -14,8 +14,10 @@ #include "base/assert.hpp" #include "base/logging.hpp" +#include "base/scope_guard.hpp" #include +#include namespace { @@ -247,12 +249,6 @@ RoutesBuilder::Processor::Processor(Processor && rhs) noexcept m_dataSource = std::move(rhs.m_dataSource); } -RoutesBuilder::Processor::~Processor() -{ - if (m_dataSource) - m_dataSourceStorage.PushDataSource(std::move(m_dataSource)); -} - void RoutesBuilder::Processor::InitRouter(VehicleType type) { if (m_router && m_router->GetVehicleType() == type) @@ -288,6 +284,9 @@ RoutesBuilder::Result RoutesBuilder::Processor::operator()(Params const & params) { InitRouter(params.m_type); + SCOPE_GUARD(returnDataSource, [&]() { + m_dataSourceStorage.PushDataSource(std::move(m_dataSource)); + }); RouterResultCode resultCode; routing::Route route("" /* router */, 0 /* routeId */); @@ -299,7 +298,7 @@ RoutesBuilder::Processor::operator()(Params const & params) false /* adjustToPrevRoute */, *m_delegate, route); - + Result result; result.m_params.m_checkpoints = params.m_checkpoints; result.m_code = resultCode; diff --git a/routing/routes_builder/routes_builder.hpp b/routing/routes_builder/routes_builder.hpp index 05503e8801..fe63464f4c 100644 --- a/routing/routes_builder/routes_builder.hpp +++ b/routing/routes_builder/routes_builder.hpp @@ -107,8 +107,6 @@ private: Processor(Processor && rhs) noexcept; - ~Processor(); - Result operator()(Params const & params); private: