[Spice-devel] [spice-gtk v1 5/7] gtk-session: move atom's debug

Victor Toso victortoso at redhat.com
Thu Feb 23 15:08:13 UTC 2017


Hi,

On Thu, Feb 23, 2017 at 02:19:31PM +0100, Pavel Grunt wrote:
> On Thu, 2017-02-23 at 14:15 +0100, Pavel Grunt wrote:
> > On Wed, 2017-02-22 at 14:11 +0100, Victor Toso wrote:
> > > From: Victor Toso <me at victortoso.com>
> > > 
> > > We already iterate in all n_atoms and get its name with
> > > gdk_atom_name(), let's move the debug there too;
> > > 
> > > As spice_util_get_debug() uses g_once(), this should not impact
> > > performance or might improve it with one memory allocation less.
> > > 
> > > While at it, move the generic SPICE_DEBUG of the function to the
> > > top.
> > > It should help us identify when the function was triggered but not
> > > used due the early returns.
> > > 
> > > Signed-off-by: Victor Toso <victortoso at redhat.com>
> > > ---
> > >  src/spice-gtk-session.c | 11 ++---------
> > >  1 file changed, 2 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> > > index 651e438..8682229 100644
> > > --- a/src/spice-gtk-session.c
> > > +++ b/src/spice-gtk-session.c
> > > @@ -604,6 +604,7 @@ static void clipboard_get_targets(GtkClipboard
> > > *clipboard,
> > >  {
> > >      SpiceGtkSession *self = free_weak_ref(user_data);
> > >  
> > > +    SPICE_DEBUG("%s:", __FUNCTION__);
> > >  
> > >      if (self == NULL || atoms == NULL)
> > >          return;
> > > @@ -628,15 +629,6 @@ static void
> > > clipboard_get_targets(GtkClipboard
> > > *clipboard,
> > >          return;
> > >      }
> > >  
> > > -    SPICE_DEBUG("%s:", __FUNCTION__);
> > > -    if (spice_util_get_debug()) {
> > > -        for (a = 0; a < n_atoms; a++) {
> > > -            name = gdk_atom_name(atoms[a]);
> > > -            SPICE_DEBUG(" \"%s\"", name);
> > > -            g_free(name);
> > > -        }
> > > -    }
> > > -
> > >      /* Set all Atoms that matches our current protocol
> > > implementation */
> > >      num_types = 0;
> > >      for (a = 0; a < n_atoms; a++) {
> > > @@ -653,6 +645,7 @@ static void clipboard_get_targets(GtkClipboard
> > > *clipboard,
> > >                  }
> > >                  if (types[t] == 0) {
> > >                      /* add type to empty slot */
> > > +                    SPICE_DEBUG("'%s'", name);
> >
> > It should go just after the gdk_atom_name() call otherwise you may
> > have a different result. Also please keep "" instead of ''

Ah, but if we do it here instead, we know the atoms that we are
storing/sending.

>
> And the indentation - imo it is easier to read
> 
> SPICE_DEBUG(" \"%s\"", name);

I prefer '' but I don't mind changing.

> 
> > 
> > Pavel
> > 
> > >                      types[t] = atom2agent[m].vdagent;
> > >                      num_types++;
> > >                      break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170223/9e866f84/attachment.sig>


More information about the Spice-devel mailing list