Skip to content

Commit f717b71

Browse files
author
zhourenjian
committed
Fixed a bug that complaining about "this.checkOrientation is not a function" for Jigloo generated codes.
1 parent 3d8f280 commit f717b71

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

sources/net.sf.j2s.java.core/src/java/lang/ClassLoader.js

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,31 @@ ClazzLoader.updateNode = function (node) {
13651365
} else {
13661366
//alert ("checking " + node.musts.length + " musts");
13671367
isMustsOK = true;
1368-
for (var i = 0; i < node.musts.length; i++) {
1368+
var mustLength = node.musts.length;
1369+
for (var i = mustLength - 1; i >= 0; i--) {
1370+
/*
1371+
* Soheil reported a strange bug:
1372+
The problem here is that, Widget functions and field are not added to
1373+
the Control !
1374+
Control is not an instance of Widget! I got an error that says
1375+
this.checkOrientation is not a function ( in Control's constructor).
1376+
1377+
When I changed the order of Drawable and Widget in the definition of
1378+
Control's constructor, the line bellow, it works fine!
1379+
$_L(["$wt.graphics.Drawable","$wt.widgets.Widget"],"$wt.widgets.Control",
1380+
... : has the error
1381+
$_L(["$wt.widgets.Widget","$wt.graphics.Drawable"],"$wt.widgets.Control",
1382+
... : does not have the error
1383+
*
1384+
* In the bug fix procedure, it's known that node.musts will
1385+
* be changed according to the later codes:
1386+
* ClazzLoader.updateNode (n); // (see about 20 lines below)
1387+
*
1388+
* As node.musts may become smaller, node.musts should be
1389+
* traversed in reverse order, so all musts are checked.
1390+
*
1391+
* TODO:
1392+
*/
13691393
var n = node.musts[i];
13701394
if (n.status < ClazzNode.STATUS_DECLARED) {
13711395
if (ClazzLoader.isClassDefined (n.name)) {
@@ -1406,7 +1430,20 @@ ClazzLoader.updateNode = function (node) {
14061430
} else { // why not break? -Zhou Renjian @ Nov 28, 2006
14071431
if (n.status == ClazzNode.STATUS_CONTENT_LOADED) {
14081432
// may be lazy loading script!
1409-
ClazzLoader.updateNode (n);
1433+
/*
1434+
window.setTimeout ((function (node) {
1435+
return function () {
1436+
ClazzLoader.updateNode (node);
1437+
};
1438+
}) (n), 1);
1439+
// */
1440+
ClazzLoader.updateNode (n); // fix above strange bug
1441+
if (node.musts.length != mustLength) {
1442+
// length changed!
1443+
mustLength = node.musts.length;
1444+
i = mustLength; // -1
1445+
isMustsOK = true;
1446+
}
14101447
}
14111448
if (n.status < ClazzNode.STATUS_DECLARED) {
14121449
isMustsOK = false;

0 commit comments

Comments
 (0)