Commit by: twl Modified files: chandler/application/Application.py 1.304 1.305 chandler/repository/query/Query.py 1.33 1.34
Log message: Patch 560 for Bug 2588, r=john,vajda This patch is a partial fix for the problems in 2588 and related bugs. It causes item attribute change detection and notification in the onIdleLoop. ViewCVS links: http://cvs.osafoundation.org/index.cgi/chandler/application/Application.py.diff?r1=text&tr1=1.304&r2=text&tr2=1.305 http://cvs.osafoundation.org/index.cgi/chandler/repository/query/Query.py.diff?r1=text&tr1=1.33&r2=text&tr2=1.34 Index: chandler/application/Application.py diff -u chandler/application/Application.py:1.304 chandler/application/Application.py:1.305 --- chandler/application/Application.py:1.304 Wed Mar 2 12:55:15 2005 +++ chandler/application/Application.py Thu Mar 3 15:29:45 2005 @@ -1,5 +1,5 @@ -__version__ = "$Revision: 1.304 $" -__date__ = "$Date: 2005/03/02 20:55:15 $" +__version__ = "$Revision: 1.305 $" +__date__ = "$Date: 2005/03/03 23:29:45 $" __copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation" __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm" @@ -507,7 +507,7 @@ if widget.IsShown() != event.GetShow(): self.needsUpdateUI = True - event.Skip() + event.Skip() def OnIdle(self, event): """ @@ -516,10 +516,37 @@ so we check for focus changes in OnIdle. Also call UpdateUI when focus changes """ + + def updateOnIdle(): + """ + This function is used to generate notifications of items that were changed + in the current (repository) view since the last time through the idle loop + """ + the_view = self.repository.view # cache the view for performance + the_view.refresh() # pickup changes from other threads + + changes = [] + + def mapChangesCallable(item, version, status, literals, references): + """ + closure to be passed to mapChanges that will produce a list of + changed items in the same format needed by + repository.query.Query.queryCallback + """ + changes.append((item.itsUUID, "changed", {})) + + # call mapChanges with flag that prevents seeing changes we've seen before + the_view.mapChanges(mapChangesCallable, True) + + # grab the list of subscribed callbacks and notify them. + for i in self.repository._notifications: + i(the_view, changes, "changeonly") + focus = wx.Window_FindFocus() if self.focus != focus: self.focus = focus self.needsUpdateUI = True + updateOnIdle() if self.needsUpdateUI: try: Index: chandler/repository/query/Query.py diff -u chandler/repository/query/Query.py:1.33 chandler/repository/query/Query.py:1.34 --- chandler/repository/query/Query.py:1.33 Tue Mar 1 13:07:32 2005 +++ chandler/repository/query/Query.py Thu Mar 3 15:29:45 2005 @@ -1,6 +1,6 @@ -__revision__ = "$Revision: 1.33 $" -__date__ = "$Date: 2005/03/01 21:07:32 $" +__revision__ = "$Revision: 1.34 $" +__date__ = "$Date: 2005/03/03 23:29:45 $" __copyright__ = "Copyright (c) 2004, 2005 Open Source Applications Foundation" __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm" @@ -185,6 +185,7 @@ #@@@ change this to batch notifications added = [] removed = [] + changed_uuids = [] for uuid, reason, kwds in changes: i = None # kill this i = view.findUUID(uuid) @@ -195,20 +196,23 @@ if flag is not None: changed = True if flag: - action = "entered" self._resultSet.append(i) added.append(i.itsUUID) else: - action = "exited" if i in self._resultSet: # should we need this? self._resultSet.remove(i) removed.append(i.itsUUID) elif i in self._removedSinceCommit: removed.append(i.itsUUID) + elif notification == 'changeonly': + if i.itsUUID in self._resultSet: + changed = True + changed_uuids.append(i.itsUUID) + self._removedSinceCommit = [] # reset for next commit if changed: - log.debug(u"RepoQuery.queryCallback: %s %s query result" % (uuid, action)) + log.debug(u"RepoQuery.queryCallback: %s %s query result" % (uuid, [added, removed, changed_uuids] )) for callbackUUID in self._otherViewSubscribeCallbacks: item = view.find (callbackUUID) method = getattr (type(item), self._otherViewSubscribeCallbacks [callbackUUID]) @@ -273,7 +277,6 @@ queryArgs = ast[1:] if queryType == 'for': - #@@@ recursive handling is a problem now, just like args plan = ForPlan(self, queryArgs, self.args) elif queryType == 'union': childPlans = [ self.__analyze(i) for i in queryArgs[0] ] @@ -459,7 +462,7 @@ # walk path, building reverse lookup to be used by changed() for i in args[1:]: try: - if (i.startswith('its')): #@@@ is this right? + if (i.startswith('its')): attr = getattr(current, i) else: attr = current.getAttribute(i) @@ -582,7 +585,6 @@ print "monitoring of multi-item paths is not yet supported" yield i except AttributeError, ae: - #@@@ log log.debug(u"AttributeError, %s" % ae) pass @@ -697,9 +699,6 @@ plans = self.__plans log.debug(u"__execute_union: plan = %s" % plans) - #@@@ DANGER - hack for self._sourceKind - fix with notification upgrade -# self._sourceKind = None - s = sets.Set(plans[0].execute()) for p in plans[1:]: s1 = sets.Set(p.execute()) _______________________________________________ Commits mailing list Commits@osafoundation.org http://lists.osafoundation.org/mailman/listinfo/commits