Skip to content

Commit d7a622a

Browse files
committed
Fix segfault in resetting output recipe
1 parent ce23e6d commit d7a622a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/rtde/rtde_client.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,14 @@ void RTDEClient::resetOutputRecipe(const std::vector<std::string> new_recipe)
281281
disconnect();
282282

283283
output_recipe_.assign(new_recipe.begin(), new_recipe.end());
284+
285+
// Reset pipeline first otherwise we will segfault, if the producer object no longer exists, when destroying the
286+
// pipeline
287+
pipeline_.reset();
288+
284289
parser_ = RTDEParser(output_recipe_);
285290
prod_ = std::make_unique<comm::URProducer<RTDEPackage>>(stream_, parser_);
291+
prod_->setRTDEReconnectionCallback(std::bind(&RTDEClient::reconnectCallback, this));
286292
pipeline_ = std::make_unique<comm::Pipeline<RTDEPackage>>(*prod_, PIPELINE_NAME, notifier_, true);
287293
}
288294

0 commit comments

Comments
 (0)