Set initial TypeInfo.lastUpdate to -1 so a Prototype with no files (lastUpdate == 0)

will be evaluated at least once. This fixes a bug with empty prototypes not having their
prototype set (i.e. get(), list(), href() etc were unavailable).
This commit is contained in:
hns 2003-11-19 14:43:22 +00:00
parent 37436236df
commit 615c9c65d1

View file

@ -44,6 +44,8 @@ public final class RhinoCore {
// table containing JavaScript prototypes // table containing JavaScript prototypes
Hashtable prototypes; Hashtable prototypes;
// timestamp of last type update
long lastUpdate = 0; long lastUpdate = 0;
// the wrap factory // the wrap factory
@ -323,7 +325,7 @@ public final class RhinoCore {
// only update prototype if it has already been initialized. // only update prototype if it has already been initialized.
// otherwise, this will be done on demand // otherwise, this will be done on demand
// System.err.println ("CHECKING PROTO "+proto+": "+type); // System.err.println ("CHECKING PROTO "+proto+": "+type);
if (type.lastUpdate > 0) { if (type.lastUpdate > -1) {
Prototype p = app.typemgr.getPrototype(type.protoName); Prototype p = app.typemgr.getPrototype(type.protoName);
if (p != null) { if (p != null) {
@ -393,7 +395,10 @@ public final class RhinoCore {
TypeInfo type = (TypeInfo) prototypes.get(protoName); TypeInfo type = (TypeInfo) prototypes.get(protoName);
if ((type != null) && (type.lastUpdate == 0)) { // if type exists and hasn't been evaluated (used) yet, evaluate it now.
// otherwise, it has already been evaluated for this request by updatePrototypes(),
// which is called before a request is handled.
if ((type != null) && (type.lastUpdate == -1)) {
Prototype p = app.typemgr.getPrototype(protoName); Prototype p = app.typemgr.getPrototype(protoName);
if (p != null) { if (p != null) {
@ -402,13 +407,6 @@ public final class RhinoCore {
if (p.getLastUpdate() > type.lastUpdate) { if (p.getLastUpdate() > type.lastUpdate) {
evaluatePrototype(p, type); evaluatePrototype(p, type);
} }
// set type.lastUpdate to 1 if it is 0 so we know we
// have initialized this prototype already, even if
// it is empty (i.e. doesn't contain any scripts/skins/actions)
if (type.lastUpdate == 0) {
type.lastUpdate = 1;
}
} }
} }
@ -833,8 +831,10 @@ public final class RhinoCore {
// the object prototype for this type // the object prototype for this type
ScriptableObject objectPrototype; ScriptableObject objectPrototype;
// timestamp of last update // timestamp of last update. This is -1 so even an empty prototype directory
long lastUpdate = 0; // (with lastUpdate == 0) gets evaluated at least once, which is necessary
// to get the prototype chain set.
long lastUpdate = -1;
// the prototype name // the prototype name
String protoName; String protoName;