locationd_thread: fix possible dangling reference to params (#23156)

pull/23170/head
Dean Lee 2021-12-09 00:46:18 +08:00 committed by GitHub
parent 0ec68a5a09
commit 48963d4b24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -497,8 +497,6 @@ int Localizer::locationd_thread() {
PubMaster pm({ "liveLocationKalman" });
SubMaster sm(service_list, nullptr, { "gpsLocationExternal" });
Params params;
while (!do_exit) {
sm.update();
for (const char* service : service_list) {
@ -523,8 +521,8 @@ int Localizer::locationd_thread() {
std::string lastGPSPosJSON = util::string_format(
"{\"latitude\": %.15f, \"longitude\": %.15f, \"altitude\": %.15f}", posGeo(0), posGeo(1), posGeo(2));
std::thread([&params] (const std::string gpsjson) {
params.put("LastGPSPosition", gpsjson);
std::thread([] (const std::string gpsjson) {
Params().put("LastGPSPosition", gpsjson);
}, lastGPSPosJSON).detach();
}
}