[Merge] lp:~mardy/location-service/last-known-position-15.04 into lp:location-service/15.04

Alberto Mardegan alberto.mardegan at canonical.com
Tue Nov 24 08:39:42 UTC 2015



Diff comments:

> 
> === modified file 'src/location_service/com/ubuntu/location/service/implementation.cpp'
> --- src/location_service/com/ubuntu/location/service/implementation.cpp	2014-08-13 13:08:22 +0000
> +++ src/location_service/com/ubuntu/location/service/implementation.cpp	2015-11-19 10:20:03 +0000
> @@ -149,5 +152,21 @@
>          new ProxyProvider{provider_selection}
>      };
>  
> -    return session::Interface::Ptr{new culs::session::Implementation(proxy_provider)};
> +    session::Interface::Ptr session_iface{new session::Implementation(proxy_provider)};
> +    std::weak_ptr<session::Interface> session_weak{session_iface};
> +    session_iface->updates().position_status.changed().connect([this, session_weak](const session::Interface::Updates::Status& status)
> +    {
> +        cul::Optional<cul::Update<cul::Position>> last_known_position =
> +            configuration.engine->updates.last_known_location.get();

We need two calls to get(): the first one for core::Property, the second one for cul::Optional. If I understand correctly, it's this second one (line 112 in this diff) which can throw. But it won't, since we check whether it's valid in line 106.

So, the only thing I can change is declaring the "last_known_position" variable as "auto", inside the if() statement. I decided not to use "auto" here, to make it more explicit what type of variable we are dealing with.
If you prefer, I'll change things they way you suggest (with the change that I'll have to keep the second call to get()), but functionality wise it will be exactly equivalent.

> +        if (last_known_position &&
> +            status == culs::session::Interface::Updates::Status::enabled)
> +        {
> +            // Immediately send the last known position to the client
> +            if (auto session_iface = session_weak.lock())
> +            {
> +                session_iface->updates().position = last_known_position.get();
> +            }
> +        }
> +    });
> +    return session_iface;
>  }


-- 
https://code.launchpad.net/~mardy/location-service/last-known-position-15.04/+merge/277960
Your team Ubuntu Phablet Team is subscribed to branch lp:location-service/15.04.



More information about the Ubuntu-reviews mailing list