diff --git a/src/java/com/threerings/presents/dobj/DObject.java b/src/java/com/threerings/presents/dobj/DObject.java index ef7d622c5..e34eaf2c5 100644 --- a/src/java/com/threerings/presents/dobj/DObject.java +++ b/src/java/com/threerings/presents/dobj/DObject.java @@ -1,5 +1,5 @@ // -// $Id: DObject.java,v 1.73 2004/06/03 18:15:03 ray Exp $ +// $Id: DObject.java,v 1.74 2004/07/03 07:16:56 mdb Exp $ package com.threerings.presents.dobj; @@ -582,11 +582,23 @@ public class DObject implements Streamable * DObjectManager.createObject it will be active until * such time as it is destroyed. */ - public boolean isActive () + public final boolean isActive () { return _omgr != null; } + /** + * Returns true if this object was once active but has now been + * destroyed and removed from the distributed object system. + * Note: this is not the opposite of {@link #isActive} which + * does not distinguish between pre-initialization and + * post-destruction. + */ + public final boolean isDestroyed () + { + return (_oid == -1); + } + /** * Don't call this function! It initializes this distributed object * with the supplied distributed object manager. This is called by the @@ -691,8 +703,15 @@ public class DObject implements Streamable */ public void startTransaction () { - if (_tevent != null) { + // sanity check + if (isDestroyed()) { + String errmsg = "Refusing to start transaction on destroyed " + + "object [dobj=" + this + "]"; + throw new IllegalArgumentException(errmsg); + + } else if (_tevent != null) { _tcount++; + } else { _tevent = new CompoundEvent(this, _omgr); } diff --git a/src/java/com/threerings/presents/server/PresentsDObjectMgr.java b/src/java/com/threerings/presents/server/PresentsDObjectMgr.java index d6f67d8c3..5f15bf496 100644 --- a/src/java/com/threerings/presents/server/PresentsDObjectMgr.java +++ b/src/java/com/threerings/presents/server/PresentsDObjectMgr.java @@ -1,5 +1,5 @@ // -// $Id: PresentsDObjectMgr.java,v 1.43 2004/06/29 03:22:22 mdb Exp $ +// $Id: PresentsDObjectMgr.java,v 1.44 2004/07/03 07:16:56 mdb Exp $ package com.threerings.presents.server; @@ -400,6 +400,7 @@ public class PresentsDObjectMgr // inactivate the object target.setManager(null); + target.setOid(-1); // deal with any remaining oid lists that reference this object Reference[] refs = (Reference[])_refs.remove(oid);