[kepler-dev] IOPortEvent bug
Christopher Brooks
cxh at eecs.berkeley.edu
Sun Jan 3 11:04:16 PST 2010
Hi Colin,
Thanks, I wrote a test that illustrates this problem and then
fixed it.
The test is
test NamedObj-8.1.0 {clone should not have _debugListener set} {
set n [java::new ptolemy.kernel.util.Workspace "N"]
set a [java::new ptolemy.kernel.util.NamedObj $n "A" ]
set listener [java::new ptolemy.kernel.util.RecorderListener]
$a addDebugListener $listener
set b [java::cast ptolemy.kernel.util.NamedObj [$a clone]]
set listenerB [java::new ptolemy.kernel.util.RecorderListener]
$b addDebugListener $listenerB
$b setName B
$b clone
list [$listener getMessages] \
[$listenerB getMessages]
} {{Cloned .A into workspace: N
} {Changed name from .A to .B
Cloned .B into workspace: N
}}
Before the fix, the result was:
{Cloned .A into workspace: N
Changed name from .A to .B
Cloned .B into workspace: N
} {Changed name from .A to .B
Cloned .B into workspace: N
}
which indicates that the listener to A is getting messages intended for B.
_Christopher
On 12/28/09 9:15 PM, Colin Enticott wrote:
> Hi Christopher,
>
> Along the same lines as this old bug, it seems _debugListeners is not
> being nulled on the new object after clone(Workspace) is called.
>
> It's funny I noticed problems with debugging after two years working
> with Kepler. It's obvious I don't debug my code enough ;-)
>
> Oh, I'm still working with Kepler-1.0.0. If this has been fixed since,
> I apologise.
>
> Kind regards,
> Colin
>
> 2008/2/23 Colin Enticott<Colin.Enticott at infotech.monash.edu.au>:
>> Thanks Dan and Christoper. Works a treat.
>>
>> Colin
>>
>> -----Original Message-----
>> From: cxh at eecs.berkeley.edu [mailto:cxh at eecs.berkeley.edu]
>> Sent: Saturday, 23 February 2008 6:14 AM
>> To: Daniel Crawl
>> Cc: Colin Enticott; Kepler-Dev
>> Subject: Re: [kepler-dev] IOPortEvent bug
>>
>> Done!
>>
>>
>> cxh at carson 192% cvs diff -D yesterday IOPort.java
>> Index: IOPort.java
>> ===================================================================
>> RCS file: /home/cvs/ptII/ptolemy/actor/IOPort.java,v
>> retrieving revision 1.260
>> retrieving revision 1.261
>> diff -r1.260 -r1.261
>> 129c129
>> < @version $Id: IOPort.java,v 1.260 2008/02/19 18:25:47 cxh Exp $
>> ---
>>> @version $Id: IOPort.java,v 1.261 2008/02/22 19:11:58 cxh Exp $
>> 420a421,424
>>>
>>> newObject._hasPortEventListeners = false;
>>> newObject._portEventListeners = null;
>>>
>> cxh at carson 193%
>>
>> On my todo list is to write some tests for the IOPortListener
>> code.
>>
>> _Christopher
>>
>> --------
>>
>>
>> Hi Colin,
>>
>> The cloned IOPort's listener list should be set to null. Since
>> Kepler CVS no longer has a separate copy of IOPort.java, could
>> someone make this change in ptII CVS?
>>
>> Thanks,
>>
>> --dan
>>
>> Colin Enticott wrote:
>> > Hi all,
>> >
>> > I was having trouble with my code and I have narrowing it down to
>> > IOPortEvents feature. There appears to be a bug in the IOPort class
>> with
>> > IOPortEvent feature and cloning. It looks like if there has been an
>> > IOPortEventListener added, when it is cloned, all the clones will have
>> a
>> > reference to the same listener list. I guess the list itself should
>> be
>> > cloned or the clone's list reference should be set back to null.
>> >
>> > It is possible if someone could have a look at this?
>> >
>> > Thanks,
>> > Colin
>> >
>> > _______________________________________________
>> > Kepler-dev mailing list
>> > Kepler-dev at ecoinformatics.org
>> >
>> http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-dev
>> >
>>
>> _______________________________________________
>> Kepler-dev mailing list
>> Kepler-dev at ecoinformatics.org
>> http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-dev
>> --------
>>
>> _______________________________________________
>> Kepler-dev mailing list
>> Kepler-dev at ecoinformatics.org
>> http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-dev
>>
>
>
>
--
Christopher Brooks, PMP University of California
CHESS Executive Director US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust Berkeley, CA 94720-1774
ph: 510.643.9841 fax:510.642.2718 (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 cell: 707.332.0670
More information about the Kepler-dev
mailing list