Another round of changes for Sourceforge bug 147484.

This commit is contained in:
clay_shooter
2006-04-23 21:01:55 +00:00
parent 0db059858a
commit ed9ef5c827
3 changed files with 24 additions and 21 deletions

View File

@@ -131,7 +131,8 @@ public abstract class ROT {
// which causes a concurrent modification exception in HashMap // which causes a concurrent modification exception in HashMap
JacobObject.debug("ROT: removing "+o.getClass().getName()); JacobObject.debug("ROT: removing "+o.getClass().getName());
} else { } else {
JacobObject.debug("ROT: removing "+o+"->"+o.getClass().getName()); // Variant toString() is probably always bad in here
JacobObject.debug("ROT: removing "+o.hashCode()+"->"+o.getClass().getName());
} }
} }
o.safeRelease(); o.safeRelease();

View File

@@ -20,8 +20,6 @@
package com.jacob.com; package com.jacob.com;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/** /**
* The multi-format data type used for all call backs and most communications * The multi-format data type used for all call backs and most communications
@@ -35,11 +33,6 @@ import java.util.Map;
public class Variant extends JacobObject { public class Variant extends JacobObject {
/** /**
* holds the list Variants that should never be freed
*/
private static Map VARIANTS_THAT_ARE_CONSTANTS = new HashMap();
/**
* Use this constant for optional parameters * Use this constant for optional parameters
*/ */
public final static com.jacob.com.Variant DEFAULT; public final static com.jacob.com.Variant DEFAULT;
@@ -71,16 +64,6 @@ public class Variant extends JacobObject {
VT_MISSING = vtMissing; VT_MISSING = vtMissing;
} }
/*
* adds all the constants to the list of those that should not be released
*/
static {
VARIANTS_THAT_ARE_CONSTANTS.put(VT_TRUE,VT_TRUE);
VARIANTS_THAT_ARE_CONSTANTS.put(VT_MISSING,VT_MISSING);
VARIANTS_THAT_ARE_CONSTANTS.put(VT_FALSE,VT_FALSE);
VARIANTS_THAT_ARE_CONSTANTS.put(DEFAULT,DEFAULT);
}
/** /**
* Pointer to MS struct. * Pointer to MS struct.
*/ */
@@ -825,6 +808,23 @@ public class Variant extends JacobObject {
safeRelease(); safeRelease();
} }
/**
* returns true if the passed in Variant is a constant that should not be freed
* @param pVariant
* @return
*/
private boolean objectIsAConstant(Variant pVariant){
if (pVariant == VT_FALSE ||
pVariant == VT_TRUE ||
pVariant == VT_MISSING ||
pVariant == DEFAULT){
return true;
} else {
return false;
}
}
/** /**
* This will release the "C" memory for the Variant * This will release the "C" memory for the Variant
* unless this Variant is one of the constants in which case * unless this Variant is one of the constants in which case
@@ -844,7 +844,7 @@ public class Variant extends JacobObject {
// finalized. this is not a big deal at all. // finalized. this is not a big deal at all.
// another way around this would be to create the constants // another way around this would be to create the constants
// in their own thread so that they would never be released // in their own thread so that they would never be released
if (!Variant.VARIANTS_THAT_ARE_CONSTANTS.containsValue(this)){ if (!objectIsAConstant(this)){
super.safeRelease(); super.safeRelease();
if (m_pVariant != 0) { if (m_pVariant != 0) {
release(); release();

View File

@@ -38,7 +38,7 @@ class VariantTest {
System.out.println("Variant value ("+v.getBoolean()+") " System.out.println("Variant value ("+v.getBoolean()+") "
+"has survived SafeRelease()"); +"has survived SafeRelease()");
} }
for ( int i = 0 ; i < 20000; i ++){ for ( int i = 0 ; i < 10; i ++){
new Variant ("xxx"+i); new Variant ("xxx"+i);
new Variant(i); new Variant(i);
new Variant ("yyy"+i); new Variant ("yyy"+i);
@@ -61,12 +61,14 @@ class VariantTest {
} else { } else {
System.out.println("VT_TRUE survived SafeRelease()"); System.out.println("VT_TRUE survived SafeRelease()");
} }
for ( int i = 0 ; i < 20000; i ++){
for ( int i = 0 ; i < 10; i ++){
new Variant ("xxx"+i); new Variant ("xxx"+i);
new Variant(i); new Variant(i);
new Variant ("yyy"+i); new Variant ("yyy"+i);
} }
ComThread.Release(); ComThread.Release();
if (Variant.VT_TRUE.getBoolean() != true){ if (Variant.VT_TRUE.getBoolean() != true){
System.out.println("VT_TRUE has been broken by ComThread.Release()"); System.out.println("VT_TRUE has been broken by ComThread.Release()");
} else { } else {