Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#4157 closed defect (fixed)

Buddy icons not visible in neighbourhood

Reported by: manuq Owned by: manuq
Priority: Immediate Milestone:
Component: Sugar Version: 0.97.x
Severity: Blocker Keywords: r+, olpc-test-passed
Cc: erikos Distribution/OS: Unspecified
Bug Status: Assigned

Description

This is because of a string encoding issue. Traceback:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/sugar3/graphics/icon.py", line 520, in do_get_preferred_height
    surface = self._buffer.get_surface()
  File "/usr/lib/python2.7/site-packages/sugar3/graphics/icon.py", line 261, in get_surface
    handle = self._load_svg(icon_info.file_name)
  File "/usr/lib/python2.7/site-packages/sugar3/graphics/icon.py", line 121, in _load_svg
    return self._loader.load(file_name, entities, self.cache)
  File "/usr/lib/python2.7/site-packages/sugar3/graphics/icon.py", line 66, in load
    return Rsvg.Handle.new_from_data(icon)
  File "/usr/lib/python2.7/site-packages/gi/types.py", line 76, in constructor
    return info.invoke(cls, *args, **kwargs)
TypeError: Item 0: Must be number or single byte string, not unicode

In Rsvg.Handle.new_from_data is being called with an unicode but it needs a str. This is because the other buddies entities come as unicode. Fix:

--- a/src/sugar3/graphics/icon.py
+++ b/src/sugar3/graphics/icon.py
@@ -57,6 +57,8 @@ class _SVGLoader(object):
 
         for entity, value in entities.items():
             if isinstance(value, basestring):
+                if isinstance(value, unicode):
+                    entity, value = str(entity), str(value)
                 xml = '<!ENTITY %s "%s">' % (entity, value)
                 icon = re.sub('<!ENTITY %s .*>' % entity, xml, icon)
             else:

After fixing this, other issues appear because the other buddiy palette needs to be fixed too.

Change History (16)

Changed 11 years ago by manuq

Toolkit patch.

comment:1 Changed 11 years ago by manuq

  • Cc erikos added
  • Keywords r? added

With both patches applied buddies can see each other in the neighborhood, make friends and send invitations. I can play Memorize collaboratively.

Pending:

  • buddies in the Journal, #3888 - I've got a new traceback with the Journal entry of shared Memorize that might be helpful
  • snowflake layout, icons of shared activities don't appear in the canvas. Nothing special in the logs.

Also I've made sure the .window -> get_window() was the last one. A grep for ".window" in sugar and sugar-toolkit-gtk3 shows:

1 - ./src/jarabe/journal/objectchooser.py:        if event.window != tree_view.get_bin_window():
2 - ./src/jarabe/journal/journalwindow.py:from sugar3.graphics.window import Window
3 - ./src/jarabe/journal/journalactivity.py:from sugar3.graphics.window import Window
4 - ./src/jarabe/desktop/favoritesview.py:            x, y, state_ = event.window.get_pointer()
5 - ./src/jarabe/intro/__init__.py:from jarabe.intro.window import IntroWindow
6 - ./src/jarabe/intro/__init__.py:from jarabe.intro.window import create_profile
7 - ./src/sugar3/activity/activity.py:from sugar3.graphics.window import Window
8 - ./src/sugar3/graphics/palettewindow.py:        if event.window != widget.get_bin_window():
9 - ./tests/graphics/intro.py:from jarabe.intro.window import IntroWindow
  • 2, 3, 5, 6, 7 and 9 are imports of modules named 'window'
  • 1, 4 and 8 are GdkEvent.window [1]

http://developer.gnome.org/gdk3/stable/gdk3-Event-Structures.html#GdkEventAny

comment:2 Changed 11 years ago by erikos

  • Bug Status changed from Unconfirmed to Assigned
  • Priority changed from Unspecified by Maintainer to Immediate
  • Severity changed from Unspecified to Blocker
  • Version changed from Unspecified to 0.97.x

When reading about the unicode issue I was reminded of the issue we had recently. So I wanted to check if we do set byte_arrays to true.

This is where we get the buddy information from. I traced that back using (import inspect; inspect.stack()) and this gets us here and this originates here.

So all is fine, we set byte_arrays to true but still the color is in unicode. Doing the same than what is done in the patch from Manuel here when we first get the color will make the buddy icon appear.

comment:3 Changed 11 years ago by manuq

The inspection erikos did was very useful to do the string convertion in the right place. For the buddy icon color, pushed as f750863f

.This attachment does the same for the Invite activity icon and for the other buddy activity. This one fixes the invite activity icon size in the buddy menu, which was causing a cairo exception because the size was not set. Should be set explicitly in the current palette implementation

comment:4 Changed 11 years ago by manuq

Pushed both, d77508b8 and 19039ee7 . Added a comment in the code to explain the need of the conversion.

Now, snowflakelayout: the activity icon is not displayed in the mesh view canvas. Also seems that the other buddies icons sometimes are not displayed too.

Changed 11 years ago by manuq

Fix requisition and allocation of Snowflakes in mesh.

comment:5 Changed 11 years ago by manuq

And the other issue, buddy not visible, might be related. Because the snowflake was being allocated outside the screen and with size = (0, 0).

comment:6 Changed 11 years ago by manuq

  • Keywords r+ olpc-test-pending added; r? removed
  • Resolution set to fixed
  • Status changed from new to closed

The move to get_preferred_size is pushed, 780a2b5a . By the way, we should investigate if we are using it properly, so filed #4181 to track it.

comment:7 Changed 11 years ago by greenfeld

  • Keywords olpc-test-passed added; olpc-test-pending removed

XOs see each other in the buddy view with adhoc networking in 13.1.0 os20/Sugar 0.98.2.

comment:8 Changed 11 years ago by dnarvaez

  • Component changed from sugar-toolkit-gtk3 to Sugar

comment:9 Changed 11 years ago by dnarvaez

  • Milestone 0.98 deleted

Milestone 0.98 deleted

Note: See TracTickets for help on using tickets.