daboide Commit Revision 302 Date: 2005-12-30 12:32:48 -0800 (Fri, 30 Dec 2005) Author: ed
Changed: U trunk/DesignerEditor.py
Log: Fixed a bug in the updateText() method that would occasionally delete entire methods.
Diff: Modified: trunk/DesignerEditor.py =================================================================== --- trunk/DesignerEditor.py 2005-12-30 04:11:07 UTC (rev 301) +++ trunk/DesignerEditor.py 2005-12-30 20:32:48 UTC (rev 302) @@ -126,6 +126,14 @@ self.select() + def _getMethodBase(self, mthd, isEvt): + cd = ("def %s(self):\n\t" % mthd, "def %s(self, evt):\n\t" % mthd) + if isEvt is None: + return cd + else: + return cd[isEvt] + + def edit(self, obj, mthd=None, nonEvent=None): """Opens an editor for the specified object and method.""" if mthd is None: @@ -143,10 +151,7 @@ txt = objCode.get(mthd, "") if not txt: mvPointer = True - if nonEvent: - txt = "def %s(self):\n\t" % mthd - else: - txt = "def %s(self, evt):\n\t" % mthd + txt = self._getMethodBase(mthd, not (nonEvent is True)) if pg is None: pg = self.pgf.appendPage(EditorPage) pg.object = obj @@ -321,9 +326,10 @@ rep = self.CodeRepository txt = pg.Text mthd = pg.method + isEmpty = (txt.strip() == "") or (txt in self._getMethodBase(mthd, None)) obj = pg.object objCode = rep.get(obj) - if not pg.Modified: + if isEmpty: # No code. Delete the key if it is found in the repository if objCode is not None: if objCode.has_key(mthd):
©2005 Ed Leafe |