Ticket #1948: 0001-sl-1948-Race-condition-with-name-widget-in-the-activ.patch

File 0001-sl-1948-Race-condition-with-name-widget-in-the-activ.patch, 2.6 KB (added by bernie, 10 years ago)
  • src/sugar/activity/activity.py

    From e8ef399b3aad32f794a5e0c9b121dd1b8c7807ef Mon Sep 17 00:00:00 2001
    From: Bernie Innocenti <bernie@codewiz.org>
    Date: Wed, 21 Apr 2010 23:32:25 -0400
    Subject: [PATCH] sl#1948: Race condition with name widget in the activity toolbar
    Organization: Sugar Labs Foundation
    X-Subversion: sucks
    
    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 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 b class ActivityToolbar(gtk.Toolbar): 
    109109            self.title = gtk.Entry()
    110110            self.title.set_size_request(int(gtk.gdk.screen_width() / 3), -1)
    111111            self.title.set_text(activity.metadata['title'])
    112             self.title.connect('changed', self.__title_changed_cb)
     112            self.title.connect('focus-out-event', self.__title_changed_cb)
    113113            self._add_widget(self.title)
    114114
    115115            activity.metadata.connect('updated', self.__jobject_updated_cb)
    class ActivityToolbar(gtk.Toolbar): 
    147147        self.insert(self.stop, -1)
    148148        self.stop.show()
    149149
    150         self._update_title_sid = None
    151 
    152150    def _update_share(self):
    153151        self._updating_share = True
    154152
    class ActivityToolbar(gtk.Toolbar): 
    183181    def __jobject_updated_cb(self, jobject):
    184182        self.title.set_text(jobject['title'])
    185183
    186     def __title_changed_cb(self, entry):
    187         if not self._update_title_sid:
    188             self._update_title_sid = gobject.timeout_add_seconds(
    189                                                 1, self.__update_title_cb)
     184    def __title_changed_cb(self, editable, event):
     185        title = editable.get_text()
    190186
    191     def __update_title_cb(self):
    192         title = self.title.get_text()
     187        # Title really changed?
     188        if title == self._activity.metadata['title']:
     189            return False
    193190
    194191        self._activity.metadata['title'] = title
    195192        self._activity.metadata['title_set_by_user'] = '1'
    class ActivityToolbar(gtk.Toolbar): 
    198195        shared_activity = self._activity.get_shared_activity()
    199196        if shared_activity:
    200197            shared_activity.props.name = title
    201 
    202         self._update_title_sid = None
    203198        return False
    204199
    205200    def _add_widget(self, widget, expand=False):