Correctly handle handover of setup states
[stockfish] / src / thread.cpp
index ce2f41f2ffeae29008890a7917fdc3302807d827..541610a1ca4b2bd5a63d16323c4d2aed991aae21 100644 (file)
@@ -414,7 +414,7 @@ void ThreadPool::wait_for_search_finished() {
 // a new search, then returns immediately.
 
 void ThreadPool::start_searching(const Position& pos, const LimitsType& limits,
-                                 const std::vector<Move>& searchMoves) {
+                                 const std::vector<Move>& searchMoves, StateStackPtr& states) {
   wait_for_search_finished();
 
   SearchTime.restart(); // As early as possible
@@ -424,6 +424,7 @@ void ThreadPool::start_searching(const Position& pos, const LimitsType& limits,
 
   RootPosition = pos;
   Limits = limits;
+  SetupStates = states; // Ownership transfer here
   RootMoves.clear();
 
   for (MoveList<LEGAL> ml(pos); !ml.end(); ++ml)