Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBernie Innocenti <bernie@codewiz.org>2010-04-22 03:32:25 (GMT)
committer Bernie Innocenti <bernie@codewiz.org>2010-04-22 03:32:25 (GMT)
commite8ef399b3aad32f794a5e0c9b121dd1b8c7807ef (patch)
treeaa2943e9aaf78914b943e5021a31f9cf195b2822 /src
parent5844cea1f337669b6d25fa274d0e0d37171556ea (diff)
sl#1948: Race condition with name widget in the activity toolbar
The fix consists in hooking to the focus-out-event to trigger a save to the datastore. Previously, we were using the change event along with a timeout of one second, which was likely to trigger while the user was still updating the edit widget.
Diffstat (limited to 'src')
-rw-r--r--src/sugar/activity/activity.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py
index c948bda..3e97485 100644
--- a/src/sugar/activity/activity.py
+++ b/src/sugar/activity/activity.py
@@ -109,7 +109,7 @@ class ActivityToolbar(gtk.Toolbar):
self.title = gtk.Entry()
self.title.set_size_request(int(gtk.gdk.screen_width() / 3), -1)
self.title.set_text(activity.metadata['title'])
- self.title.connect('changed', self.__title_changed_cb)
+ self.title.connect('focus-out-event', self.__title_changed_cb)
self._add_widget(self.title)
activity.metadata.connect('updated', self.__jobject_updated_cb)
@@ -147,8 +147,6 @@ class ActivityToolbar(gtk.Toolbar):
self.insert(self.stop, -1)
self.stop.show()
- self._update_title_sid = None
-
def _update_share(self):
self._updating_share = True
@@ -183,13 +181,12 @@ class ActivityToolbar(gtk.Toolbar):
def __jobject_updated_cb(self, jobject):
self.title.set_text(jobject['title'])
- def __title_changed_cb(self, entry):
- if not self._update_title_sid:
- self._update_title_sid = gobject.timeout_add_seconds(
- 1, self.__update_title_cb)
+ def __title_changed_cb(self, editable, event):
+ title = editable.get_text()
- def __update_title_cb(self):
- title = self.title.get_text()
+ # Title really changed?
+ if title == self._activity.metadata['title']:
+ return False
self._activity.metadata['title'] = title
self._activity.metadata['title_set_by_user'] = '1'
@@ -198,8 +195,6 @@ class ActivityToolbar(gtk.Toolbar):
shared_activity = self._activity.get_shared_activity()
if shared_activity:
shared_activity.props.name = title
-
- self._update_title_sid = None
return False
def _add_widget(self, widget, expand=False):