Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2012-12-10 18:02:17 (GMT)
committer Daniel Drake <dsd@laptop.org>2012-12-10 18:02:17 (GMT)
commitf4ebbf563c4e703d1e26fc48380d4813a4416b02 (patch)
treef4c2c429695c401369b30c8fc68ec4635f72b6eb
parente6ed1dfb74ce578de96f2f228dd5f1964f0b0d2b (diff)
Call into bundle registry from main thread (#12272)
When installing/updating bundles, bundleregistry will fire the 'bundle-added' signal directly. This triggers signal handlers in Sugar's favoritesview and activitylist classes which are not thread-safe. Triggering the signal in this way was resulting in weird UI hangs after the updater has been run. Avoid these issues by calling into the bundle registry only from the main thread.
-rwxr-xr-xsrc/view.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/view.py b/src/view.py
index efc8de6..76708d5 100755
--- a/src/view.py
+++ b/src/view.py
@@ -13,10 +13,11 @@ from gi.repository import GLib
from gi.repository import GObject
GLib.threads_init()
+import logging
import gettext
import os
import re
-from threading import Thread
+from threading import Thread, Event
import gettext
_ = lambda msg: gettext.dgettext('sugar-update-control', msg)
@@ -524,6 +525,11 @@ class ActivityUpdater(SectionView):
# and start refreshing.
self.refresh_cb(None, None)
+ def install_cb(self, registry, bundle, event):
+ bundle.install_or_upgrade(registry)
+ event.set()
+ return False
+
def download_cb(self, widget, event, data=None):
"""Invoked when the 'ok' button is clicked."""
from sugar3.bundle.activitybundle import ActivityBundle
@@ -539,6 +545,7 @@ class ActivityUpdater(SectionView):
# get activity registry
from jarabe.model.bundleregistry import get_registry
registry = get_registry() # requires a dbus-registered main loop
+ install_event = Event()
# progress bar bookkeeping.
counts = [0, self.activity_list.updates_selected(), 0]
def p(n, extra, icon):
@@ -558,8 +565,11 @@ class ActivityUpdater(SectionView):
b = actutils.BundleHelper(f)
p(counts[2], _('Installing %s...') % b.get_name(),
_svg2pixbuf(b.get_icon_data()))
- b.install_or_upgrade(registry)
+ install_event.clear()
+ GLib.idle_add(self.install_cb, registry, b, install_event)
+ install_event.wait()
except:
+ logging.exception("Failed to install bundle")
pass # XXX: use alert to indicate install failure.
if os.path.exists(f):
os.unlink(f)