[Spice-devel] [PATCH 4/4] client: foreign-menu: pass "active" param when creating a ForeignMenu (#769020)

Alon Levy alevy at redhat.com
Tue Dec 20 09:07:57 PST 2011


On Tue, Dec 20, 2011 at 06:52:58PM +0200, Uri Lublin wrote:
> The default stays the same -- false.
> 
> A race could prevent setting ForeignMenu::_active correctly.
> That happened when Application::on_app_activated was called before
> _foriegn_menu was created. When foriegn_menu was created its
> _active defaults to false, and that has not changed, until focus
> was taken out and back in spice-client window.
> 
> This caused usbrdr to sometimes not auto-share devices, unless
> the user switched focus to a different application and back to
> spicec.
> 

ACK.

> The fix updates ForiegnMenu::_active upon creation.
> ---
>  client/application.cpp  |    2 +-
>  client/foreign_menu.cpp |    4 ++--
>  client/foreign_menu.h   |    2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/client/application.cpp b/client/application.cpp
> index decf8a1..e120dfe 100644
> --- a/client/application.cpp
> +++ b/client/application.cpp
> @@ -599,7 +599,7 @@ int Application::run()
>  
>  void Application::on_start_running()
>  {
> -    _foreign_menu.reset(new ForeignMenu(this));
> +    _foreign_menu.reset(new ForeignMenu(this, _active));
>      if (_enable_controller) {
>          _controller.reset(new Controller(this));
>          return;
> diff --git a/client/foreign_menu.cpp b/client/foreign_menu.cpp
> index 00cc57c..d1df49d 100644
> --- a/client/foreign_menu.cpp
> +++ b/client/foreign_menu.cpp
> @@ -36,9 +36,9 @@
>  #define PIPE_NAME "/tmp/SpiceForeignMenu-%lu.uds"
>  #endif
>  
> -ForeignMenu::ForeignMenu(ForeignMenuInterface *handler)
> +ForeignMenu::ForeignMenu(ForeignMenuInterface *handler, bool active)
>      : _handler (handler)
> -    , _active (false)
> +    , _active (active)
>      , _refs (1)
>  {
>      char pipe_name[PIPE_NAME_MAX_LEN];
> diff --git a/client/foreign_menu.h b/client/foreign_menu.h
> index 2fc4e53..6138087 100644
> --- a/client/foreign_menu.h
> +++ b/client/foreign_menu.h
> @@ -38,7 +38,7 @@ public:
>  
>  class ForeignMenu : public NamedPipe::ListenerInterface {
>  public:
> -    ForeignMenu(ForeignMenuInterface *handler);
> +    ForeignMenu(ForeignMenuInterface *handler, bool active = false);
>      virtual ~ForeignMenu();
>  
>      ForeignMenu* ref() { _refs++; return this;}
> -- 
> 1.7.1
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list