[Positioner] Mobile: fix copy constructor segfault

master
Matteo Cypriani 7 years ago
parent ecb9a689b5
commit 41640da203

@ -21,7 +21,7 @@
Mobile::Mobile(const Mobile &m):
WifiDevice(m), last_results(m.last_results)
WifiDevice(m), last_request(nullptr), last_results(m.last_results)
{
update_last_request() ;
}
@ -42,13 +42,20 @@ void Mobile::update_last_request()
{
if (last_results.empty())
{
delete last_request ;
last_request = nullptr ;
if (last_request)
{
delete last_request;
last_request = nullptr;
}
return ;
}
if (! last_request)
last_request = new Request(*last_results.get_request()) ;
{
const Request *r = last_results.get_request();
if (r)
last_request = new Request(*r);
}
else
*last_request = *last_results.get_request() ;

Loading…
Cancel
Save