[Pkg-sugar-commit] [sugar-toolkit] 109/118: sl#1948: Race condition with name widget in the activity toolbar

Jonas Smedegaard dr at jones.dk
Thu Apr 16 18:49:48 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.84.10-1
in repository sugar-toolkit.

commit e8ef399b3aad32f794a5e0c9b121dd1b8c7807ef
Author: Bernie Innocenti <bernie at codewiz.org>
Date:   Wed Apr 21 23:32:25 2010 -0400

    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.
---
 src/sugar/activity/activity.py | 17 ++++++-----------
 1 file 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):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-sugar/sugar-toolkit.git



More information about the pkg-sugar-commit mailing list