In TclBlend 1.2.6, when a ReflectObject is created to represent a TclObject,
the ReflectObject does not preserve() the TclObject.  But the ReflectObject
holds on to the TclObject for a long duration in its hash table.  When the
TclObject is dereferenced, it can cause the ReflectObject to contain an
invalid TclObject.

Patch:

***
/space/home/jwu/tcl/blend.orig/tclBlend1.2.6/src/tcljava/tcl/lang/ReflectObj
ect.java        Tue Aug 22 10:35:03 2000
--- ReflectObject.java  Wed Aug 23 10:24:45 2000
***************
*** 566,571 ****
--- 566,579 ----
        
        roRep.useCount = 1;
        roRep.isValid  = true;  
+ 
+       if (obj instanceof TclObject) {
+           // as the object being reflected is kept for a long time,
+           // and the object being reflected is a TclObject, then
+           // we must increment the ref count the TclObject.  Else,
+           // the TclObject may not be valid later.
+           ((TclObject) obj).preserve();
+       }
        
        if (debug) {
            System.out.println("POST REGISTER DUMP");
***************
*** 625,630 ****
--- 633,645 ----
  
        removeFromReflectTable(this);
  
+       if (javaObj instanceof TclObject) {
+           // if the object being reflected is a TclObject, then we
+           // need to release it to signal that we no longer need to
+           // use it.
+           ((TclObject) javaObj).release();
+       }
+       
        ownerInterp = null;
        javaObj = null;
        javaClass = null;

----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe:    send mail to [EMAIL PROTECTED]  
                 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
                 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com

Reply via email to