[Spice-devel] [spice-gtk v1 1/7] gtk-session: check if retrieving clipboard data failed

Pavel Grunt pgrunt at redhat.com
Fri Feb 24 11:48:53 UTC 2017


On Thu, 2017-02-23 at 16:05 +0100, Victor Toso wrote:
> Hi,
> 
> On Thu, Feb 23, 2017 at 02:01:56PM +0100, Pavel Grunt wrote:
> > On Wed, 2017-02-22 at 14:11 +0100, Victor Toso wrote:
> > > From: Victor Toso <me at victortoso.com>
> > > 
> > > In case of failure,
> > 
> > Do we want to know about the failure?
> 
> Not sure. Maybe a debug message? I did not check how this can happen
> in
> our case.
> 
> > 
> > >  the GdkAtom *atoms will be set to NULL.
> > > Including this check to an early return.
> > > 
> > > Signed-off-by: Victor Toso <victortoso at redhat.com>
> > > ---
> > >  src/spice-gtk-session.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> > > index 0426d8f..3c78e6a 100644
> > > --- a/src/spice-gtk-session.c
> > > +++ b/src/spice-gtk-session.c
> > > @@ -604,7 +604,8 @@ static void
> > > clipboard_get_targets(GtkClipboard
> > > *clipboard,
> > >  {
> > >      SpiceGtkSession *self = free_weak_ref(user_data);
> > >  
> > > -    if (self == NULL)
> > > +
> > > +    if (self == NULL || atoms == NULL)
> > >          return;
> > 
> > Maybe add a comment ? no atoms => no targets
> > 
> > >  
> > >      g_return_if_fail(SPICE_IS_GTK_SESSION(self));
> > 
> > OT: these checks for 'self' are strange - the first one hides the
> > other
> 
> Yes, but I think those _IS_OBJECT() can crash on NULL.

It uses G_TYPE_CHECK_INSTANCE_TYPE which "..If instance is NULL, FALSE
will be returned."

>  I don't see how
> this would *not* be SpiceGtkSession* as *we* set it in the GWeakRef.
> 
> I'll include it in this patch series as this patch series is only
> playing with this function.
> 
> > 
> > Pavel


More information about the Spice-devel mailing list