20 Aug 13:20
Difficult bug
From: Jerome Laheurte <fraca7@...>
Subject: Difficult bug
Newsgroups: gmane.comp.sysutils.pim.taskcoach.devel
Date: 2008-08-20 11:24:44 GMT
Subject: Difficult bug
Newsgroups: gmane.comp.sysutils.pim.taskcoach.devel
Date: 2008-08-20 11:24:44 GMT
Hi, Frank. I found a bug and I'm at loss as to how to fix it; I see
several solutions but they may have other impacts...
The bug: Start with an empty file, create a category, then a
subcategory, then a task. Edit the parent category and click OK. Edit
the task. The result:
File
"/home/jla/WinHome/dev/fraca7/taskcoach-trunk/taskcoachlib/gui/dialog/editor.py",
line 531, in getCategoryWithIndex
category = children[i]
IndexError: list index out of range
After some digging, I found out that when the category's state is
saved, patterns.Composite makes a copy of the children. Thus, when the
edit is undone, the category's children are replaced with copies. But
the global list of categories keeps the old versions.
As default object comparison is based on id, a category and its copy
are considered different and bad things happen.
First thought: overload __contains__ in Sorter to compare items
according to their __id. This fails because the copy generates a new
__id (and I saw a comment about that so I guess it's intended). Would
keeping the __id in a copy break something ? Does this fix other
potential bugs due to the same root ?
Second thought: avoid copying in __getstate__, just keep the original
instances. I'm pretty sure this will have side effects, though a
(Continue reading)
Cheers, Frank
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
cheers, Frank
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
RSS Feed