Switched to a safe subscriber.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2983 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2004-03-06 14:55:50 +00:00
parent e39ff5ffd3
commit 8a54e85914
@@ -1,5 +1,5 @@
// //
// $Id: ObjectEditorPanel.java,v 1.4 2004/03/06 12:00:39 mdb Exp $ // $Id: ObjectEditorPanel.java,v 1.5 2004/03/06 14:55:50 mdb Exp $
package com.threerings.admin.client; package com.threerings.admin.client;
@@ -8,17 +8,16 @@ import java.lang.reflect.Modifier;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.event.AncestorEvent;
import com.samskivert.swing.ScrollablePanel; import com.samskivert.swing.ScrollablePanel;
import com.samskivert.swing.VGroupLayout; import com.samskivert.swing.VGroupLayout;
import com.samskivert.swing.event.AncestorAdapter;
import com.samskivert.swing.util.SwingUtil; import com.samskivert.swing.util.SwingUtil;
import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.ObjectAccessException; import com.threerings.presents.dobj.ObjectAccessException;
import com.threerings.presents.dobj.Subscriber; import com.threerings.presents.dobj.Subscriber;
import com.threerings.presents.util.PresentsContext; import com.threerings.presents.util.PresentsContext;
import com.threerings.presents.util.SafeSubscriber;
import com.threerings.admin.Log; import com.threerings.admin.Log;
import com.threerings.admin.data.ConfigObject; import com.threerings.admin.data.ConfigObject;
@@ -49,18 +48,11 @@ public class ObjectEditorPanel extends ScrollablePanel
// keep this business around // keep this business around
_ctx = ctx; _ctx = ctx;
_key = key; _key = key;
_oid = oid;
// when we're hidden, we want to clear out our subscriptions // we'll use this to safely subscribe to and unsubscribe from the
addAncestorListener(new AncestorAdapter () { // config object
public void ancestorAdded (AncestorEvent event) { _safesub = new SafeSubscriber(oid, this);
// subscribe to our object the first time we're shown _safesub.subscribe(_ctx.getDObjectManager());
if (_object == null) {
_ctx.getDObjectManager().subscribeToObject(
_oid, ObjectEditorPanel.this);
}
}
});
} }
// documentation inherited from interface // documentation inherited from interface
@@ -75,10 +67,9 @@ public class ObjectEditorPanel extends ScrollablePanel
*/ */
public void cleanup () public void cleanup ()
{ {
if (_object != null) { // clear out our subscription
_ctx.getDObjectManager().unsubscribeFromObject(_oid, this); _safesub.unsubscribe(_ctx.getDObjectManager());
_object = null; _object = null;
}
// clear out our field editors // clear out our field editors
removeAll(); removeAll();
@@ -116,6 +107,6 @@ public class ObjectEditorPanel extends ScrollablePanel
protected PresentsContext _ctx; protected PresentsContext _ctx;
protected String _key; protected String _key;
protected int _oid; protected SafeSubscriber _safesub;
protected ConfigObject _object; protected ConfigObject _object;
} }