Opened 11 years ago

Closed 11 years ago

#4605 closed defect (fixed)

"View Source" crashes in every activity

Reported by: manuq Owned by: manuq
Priority: Urgent Milestone: Unspecified
Component: Sugar Version: Unspecified
Severity: Unspecified Keywords:
Cc: Distribution/OS: Unspecified
Bug Status: New


I will own this one. Traceback:

1376683141.083415 DEBUG ViewSource: ViewSource paths: '/home/manuq/Activities/GearsActivity.activity' None None
Traceback (most recent call last):
  File "/home/manuq/prog/sugar-build/build/out/install/lib/python2.7/site-packages/jarabe/view/", line 122, in __view_source__cb
  File "/home/manuq/prog/sugar-build/build/out/install/lib/python2.7/site-packages/jarabe/view/", line 109, in setup_view_source
    sugar_toolkit_path, activity.get_title())
  File "/home/manuq/prog/sugar-build/build/out/install/lib/python2.7/site-packages/jarabe/view/", line 180, in __init__
    self._selected_sugar_file = os.path.join(sugar_toolkit_path, file_name)
  File "/usr/lib64/python2.7/", line 68, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'

Change History (14)

comment:1 Changed 11 years ago by dnarvaez

  • Bug Status changed from Unconfirmed to New

Same happens for chat here, which is not a web activity.

comment:2 Changed 11 years ago by manuq

  • Summary changed from "View Source" crashes in web activities to "View Source" crashes in every activity

comment:3 Changed 11 years ago by walter

This is a recent regression because view source works with both Python and Web activities in a slightly out of date Sugar build.

Last edited 11 years ago by walter (previous) (diff)

comment:4 Changed 11 years ago by erikos

This is an issue because View Source tries to display the gtk2 sugar-toolkit, which is not present anymore in sugar-build. You can see this by displaying the gtk3 toolkit, like:

diff --git a/src/jarabe/view/ b/src/jarabe/view/
index 99b9c9d..a486005 100644
--- a/src/jarabe/view/
+++ b/src/jarabe/view/
@@ -101,8 +101,8 @@ def setup_view_source(activity):
     sugar_toolkit_path = None
     for path in sys.path:
         if path.endswith('site-packages'):
-            if os.path.exists(os.path.join(path, 'sugar')):
-                sugar_toolkit_path = os.path.join(path, 'sugar')
+            if os.path.exists(os.path.join(path, 'sugar3')):
+                sugar_toolkit_path = os.path.join(path, 'sugar3')
     view_source = ViewSource(window_xid, bundle_path, document_path,

A more fallback proven fix would be to fallback on the gtk2 toolkit if the gtk3 one is not available.

comment:5 Changed 11 years ago by erikos

It would be even better to display the toolkit which is used in the activity currently running.

(Did I ever say that I do not fine the toolkit-view-source icon a good one? Using the XO icon for that purpose is misleading and does not transport any information about it's purpose to me.)

comment:6 Changed 11 years ago by walter

Ideas for new icons most welcome. Problem is, there is no icon for the toolkit (yet).

I will continue to support the idea of view source for the toolkit: we want to demystify as much as we can. On my wish list is a way to let the end user modify the toolkit (a la duplicate). The problem is how to let them do that without risking crashing Sugar in an unrecoverable way.

comment:7 Changed 11 years ago by erikos

I guess an icon similar to the settings one would be used normally for that purpose (the screw-wrench). Maybe an icon based on tools for the sandbox would be joyful but still meaningful:

comment:8 Changed 11 years ago by manuq

Good findings Simon!

What about?

  • show toolkit-gtk3 if it is a GTK3 activity
  • show sugar-web if it is a web activity

And about the icon, let's move the discussion to the mailing list.

comment:9 Changed 11 years ago by erikos

Thanks Manuel for moving the icon discussion to the ml.

We can differentiate whether it is a web activity or a gtk3 one by looking at the exec command in the activity bundle ( file):

activity_bundle = ActivityBundle(bundle_path)
if activity_bundle.get_command() == 'sugar-activity-web'
    do stuff here

We currently (as the best of my knowledge) ship the web toolkit system wide, a copy is included in each activity. For that reason it is already part of the tree displayed under the activity option. A few options:

  • not displaying the toolkit option at all in the case of a sugar-web activity
  • displaying the subtree of the copy in the activity folder
  • leaving a note under the toolkit option in the case of a sugar-web activity where to find the toolkit for the sugar-web activity, maybe even adding a button to switch to it in the other option

comment:10 Changed 11 years ago by manuq

Excellent. I would go with the second option: display the subtree of the copy in the activity folder. Because it will be consistent with GTK activities, and will show the actual sugar-web that the activity is using, not a system wide or upstream master sugar-web.

comment:12 Changed 11 years ago by manuq

More side notes:

  • When toolkit is selected, in the toolbar 'Sugar Toolkit' has quotes around
  • View Source takes time to load, and there is no feedback to the user, so selecting "view source" in the palette gives the impression of not doing anything

comment:13 Changed 11 years ago by manuq


I think we should not delay the fix for this blocker. Better try to not fall in a cascade of other lesser bugs related with View Source. Let's open bugs for them instead.

comment:14 Changed 11 years ago by dnarvaez

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.