Fix #8044 - fixing varous crashes, correct tree drop location and empty nodes after...
authorAlan <alan@roojs.com>
Thu, 22 Feb 2024 07:35:06 +0000 (15:35 +0800)
committerAlan <alan@roojs.com>
Thu, 22 Feb 2024 07:35:06 +0000 (15:35 +0800)
src/Builder4/WindowLeftProps.bjs
src/Builder4/WindowLeftProps.vala
src/Builder4/WindowLeftTree.bjs
src/Builder4/WindowLeftTree.vala
src/Builder4/WindowRooView.bjs
src/Builder4/WindowRooView.vala
src/JsRender/JsRender.vala
src/JsRender/Node.vala

index 7df8fe4..683a988 100644 (file)
              " var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();",
              " var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();",
              "",
-             "",
+             " if (item == null) {",
+             " \treturn;",
+             "}",
              "item.bind_property(\"to_display_name_prop\",",
              "                    lb, \"label\",",
              "                   GLib.BindingFlags.SYNC_CREATE);",
              "\tcb.hide();",
              "\t",
              "\tvar prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();",
+             " \tif (prop == null || _this.node == null ) {",
+             " \t\tGLib.error(\"something is wrong\");",
+             "\t \treturn;",
+             "\t}",
+             "\tif ( _this.node.fqn() == \"\") {",
+             " \t\tGLib.debug(\"node is missing fqn\");",
+             "\t \treturn;",
+             "\t}",
+             "\t",
              "\t//GLib.debug(\"prop = %s\", prop.get_type().name());",
              "\t//GLib.debug(\"prop.val = %s\", prop.val);",
              "\t//GLib.debug(\"prop.key = %s\", prop.to_display_name());",
         "\t\t}",
         "\t\tif (l.get_visible()) {",
         "\t\t \t_this.stop_editor();",
+        "\t\t \tif (prop.parent == null) {",
+        "\t\t \t\treturn;",
+        "\t \t\t}",
         "\t    \t_this.show_editor(_this.file, prop.parent, prop);",
         "\t\t",
         "\t\t}",
     "    \t",
     "    }",
     "    ",
-    "    GLib.debug(\"load leftprops\\n\");",
+    "    GLib.debug(\"load leftprops\");",
     "",
     "    this.node = node;",
     "    this.file = file;",
     "              ",
     "    //this.get('/RightEditor').el.hide();",
     "    if (node ==null) {",
+    "        GLib.debug(\"node is null return\");",
     "        return ;",
     "    }",
     "",
index 16720bc..eae35e4 100644 (file)
@@ -287,7 +287,7 @@ public class Xcls_LeftProps : Object
                
            }
            
-           GLib.debug("load leftprops\n");
+           GLib.debug("load leftprops");
        
            this.node = node;
            this.file = file;
@@ -297,6 +297,7 @@ public class Xcls_LeftProps : Object
                      
            //this.get('/RightEditor').el.hide();
            if (node ==null) {
+               GLib.debug("node is null return");
                return ;
            }
        
@@ -1713,6 +1714,9 @@ public class Xcls_LeftProps : Object
                                }
                                if (l.get_visible()) {
                                        _this.stop_editor();
+                                       if (prop.parent == null) {
+                                               return;
+                                       }
                                _this.show_editor(_this.file, prop.parent, prop);
                                
                                }
@@ -2181,7 +2185,9 @@ public class Xcls_LeftProps : Object
                         var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();
                         var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
                        
-                       
+                        if (item == null) {
+                               return;
+                       }
                        item.bind_property("to_display_name_prop",
                                            lb, "label",
                                           GLib.BindingFlags.SYNC_CREATE);
@@ -2349,6 +2355,15 @@ public class Xcls_LeftProps : Object
                                cb.hide();
                                
                                var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
+                               if (prop == null || _this.node == null ) {
+                                       GLib.error("something is wrong");
+                                       return;
+                               }
+                               if ( _this.node.fqn() == "") {
+                                       GLib.debug("node is missing fqn");
+                                       return;
+                               }
+                               
                                //GLib.debug("prop = %s", prop.get_type().name());
                                //GLib.debug("prop.val = %s", prop.val);
                                //GLib.debug("prop.key = %s", prop.to_display_name());
index bab93d9..a4deaf6 100644 (file)
           "drop" : [
            "(v, x, y) => {",
            "\t",
+           "\t// must get the pos before we clear the hightlihg.",
+           " \tvar pos = \"\";",
+           " \tvar row = _this.view.getRowAt(x,y, out pos);",
            "\tthis.addHighlight(null,\"\");",
            " ",
            " \tvar is_shift = _this.keystate.is_shift > 0;",
            " ",
-           " \tvar pos = \"\";",
+           "",
            " \t// -- get position..",
            " \tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
            "\t\t// still dragging same node",
            " \t     ",
            "       ",
            "    var dropNode = new JsRender.Node(); ",
-           "\tdropNode.loadFromJsonString(v.get_string(), 1);",
+           "\tdropNode.loadFromJsonString(v.get_string(), 2);",
+           "\tGLib.debug(\"dropped node %s\", dropNode.toJsonString());",
+           "\t",
+           "\t",
            "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(dropNode.fqn());",
            "   ",
            "    // if there are not items in the tree.. the we have to set isOver to true for anything..",
            "\t\t\treturn false;\t",
            "\t\t}",
            "\t\t// add new node to top..",
-           "\t\t",
+           "\t\tGLib.debug(\"adding to top\");",
            "\t\t",
            "\t\t var m = (GLib.ListStore) _this.model.el.model;",
            "     \t_this.main_window.windowstate.file.tree = dropNode;  ",
            "",
            "",
            "",
-           "\tvar row = _this.view.getRowAt(x,y, out pos);",
+           "",
            "\tif (row < 0) {",
+           "\t\tGLib.debug(\"could not get row %d,%d, %s\", (int)x,(int)y,pos);",
            "\t\treturn   false; //Gdk.DragAction.COPY;",
            "\t}",
            "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
            " \t",
            " \tswitch(pos) {",
            " \t\tcase \"over\":",
-           "\t \t\tnode.appendChild(dropNode);",
+           "",
            "\t \t\tif (is_shift && _this.view.dragNode != null) {",
            "\t\t \t\t_this.model.selectNode(null); ",
            "\t\t \t\t_this.view.dragNode.remove();",
            "\t \t\t}",
-           "\t \t\t\t",
+           " \t \t\tnode.appendChild(dropNode);\t\t\t",
            "\t \t\tdropNode.updated_count++;",
            " \t\t\t_this.model.selectNode(dropNode); ",
            " \t\t\t",
            " \t\tcase \"above\":",
            " \t\t\tGLib.debug(\"Above - insertBefore\");",
            " \t\t",
-           "\t\t\tnode.parent.insertBefore(dropNode, node);",
+           "",
            "\t \t\tif (is_shift && _this.view.dragNode != null) {",
            "\t\t \t\t_this.model.selectNode(null); \t \t\t",
            "\t\t \t\t_this.view.dragNode.remove();",
            "\t \t\t}",
+           "\t\t\tnode.parent.insertBefore(dropNode, node);\t \t\t",
            "\t\t\tdropNode.updated_count++;",
            " \t\t\t_this.model.selectNode(dropNode); \t\t\t",
            " \t\t\t_this.changed();",
            " ",
            "\tvar is_shift = _this.keystate.is_shift > 0;",
            "\t",
-           "\tGLib.debug(\"shift is    %s\", _this.keystate.is_shift > 0 ? \"SHIFT\" : \"-\");",
+           "\t//GLib.debug(\"shift is    %s\", _this.keystate.is_shift > 0 ? \"SHIFT\" : \"-\");",
            "\tstring pos; // over / before / after..",
            "",
            "    //GLib.debug(\"got drag motion\");",
            "   \ttry {",
            "  \t\tcont.get_value(ref v);",
            "\t} catch (GLib.Error e) {",
-           "\t    GLib.debug(\"failed to get drag value\");",
+           "\t   // GLib.debug(\"failed to get drag value\");",
            "\t\treturn Gdk.DragAction.COPY;\t ",
            "\t",
            "\t}",
            "     foreach(var dp in drop_on_to) {",
            "     \tstr += dp;",
            " \t}",
-           " \tGLib.debug(\"droplist: %s\", string.joinv(\", \", str));",
+           " \t//GLib.debug(\"droplist: %s\", string.joinv(\", \", str));",
            "     ",
            "     ",
            "    // if there are not items in the tree.. the we have to set isOver to true for anything..",
            "    }",
            "    ",
            "    ",
-           " \tGLib.debug(\"check is over\");",
+           "",
            " \t ",
            "    // if path of source and dest are inside each other..",
            "    // need to add source info to drag?",
            "    // the fail();",
            " \tvar row = _this.view.getRowAt(x,y, out pos);",
-           " \t",
+           " \t//GLib.debug(\"check is over %d, %d, %s\", (int)x,(int)y, pos);",
+           "",
            " \tif (row < 0) {",
            "\t\tthis.addHighlight(null, \"\");\t",
            "\t \treturn Gdk.DragAction.COPY;",
            "\t",
            "\tvar node =  (JsRender.Node)tr.get_item();",
            "\t",
-           "\tGLib.debug(\"Drop over node: %s\", node.fqn());",
+           "\t//GLib.debug(\"Drop over node: %s\", node.fqn());",
            "\t",
            "",
            " \tif (pos == \"above\" || pos == \"below\") {",
            "\t\tif (node.parent == null) {",
-           "\t\t\tGLib.debug(\"no parent try center\");",
+           "\t\t\t//GLib.debug(\"no parent try center\");",
            "\t\t\tpos = \"over\";",
            "\t\t} else {",
            "\t \t\t ",
            "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
-           "\t\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.parent.fqn());",
+           "\t\t\t\t//GLib.debug(\"drop on does not contain %s - try center\" , node.parent.fqn());",
            "\t \t\t\tpos = \"over\";",
            " \t\t\t} else {",
-           "\t\t\t\tGLib.debug(\"drop  contains %s - using %s\" , node.parent.fqn(), pos);",
+           "\t\t\t\t//GLib.debug(\"drop  contains %s - using %s\" , node.parent.fqn(), pos);",
            "\t\t\t\tif (_this.view.dragNode  != null && is_shift) {",
            "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
            "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
            " \t}",
            " \tif (pos == \"over\") {",
            "\t \tif (!drop_on_to.contains(node.fqn())) {",
-           "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
+           "\t\t\t//GLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
            "\t\t\tthis.addHighlight(null, \"\"); ",
            "\t\t\treturn is_shift ?  Gdk.DragAction.MOVE :  Gdk.DragAction.COPY;\t\t",
            "\t\t}",
            "\t\tif (_this.view.dragNode  != null && is_shift) {",
            " \t\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
-           "\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
+           "\t \t\t\t//GLib.debug(\"shift drop not self not allowed\");",
            " \t\t\t\tthis.addHighlight(null, \"\");",
            " \t\t\t\treturn Gdk.DragAction.COPY;\t",
            " \t\t\t}",
           "(Gtk.Widget? w, string hl) {",
           "\tif (this.highlightWidget != null) {",
           "\t\tvar ww  = this.highlightWidget;",
-          "\t\tGLib.debug(\"clear drag from previous highlight\");",
+          "\t\t//GLib.debug(\"clear drag from previous highlight\");",
           "\t\tif (ww.has_css_class(\"drag-below\")) {",
           "\t\t\t ww.remove_css_class(\"drag-below\");",
           "\t\t}",
           "\t\t}",
           "\t}",
           "\tif (w != null) {",
-          "\t\tGLib.debug(\"add drag=%s to widget\", hl);\t",
+          "\t\t//GLib.debug(\"add drag=%s to widget\", hl);\t",
           "\t\tif (!w.has_css_class(\"drag-\" + hl)) {",
           "\t\t\tw.add_css_class(\"drag-\" + hl);",
           "\t\t}",
            "\t    // why dup_?",
            "\t    ",
            "",
-           "\t    GLib.debug (\"calling left_tree.node_selected\");",
+           "\t    GLib.debug (\"calling left_tree.node_selected %s\", snode.toJsonString());",
            "\t    _this.node_selected(snode);",
            "\t   ",
            "\t     ",
           "() {",
           "  if (this.el.selected_item == null) {",
           "\t\treturn null;",
-          "  }\t\t\t        ",
+          "  }\t",
+          "   ",
+          "  ",
           "   var tr = (Gtk.TreeListRow)this.el.selected_item;",
+          "  ",
           "   return (JsRender.Node)tr.get_item();",
           "\t ",
           "}"
            "listeners" : {
             "bind" : [
              "(listitem) => {",
-             "\t GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
+             "\t// GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
              "\t",
              "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
              "\tvar expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();",
              "\t",
              "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
              "\tvar node = (JsRender.Node) lr.get_item();",
-             "\t",
-             "   GLib.debug(\"node is %s\", node.get_type().name());",
+             "\tif (node == null || node.fqn() == \"\") {",
+             "\t\treturn;",
+             "\t}",
+             "   //GLib.debug(\"node is %s\", node.get_type().name());",
              "// was item (1) in old layout",
              "",
              "\t",
index 06cd3ad..a878cba 100644 (file)
@@ -1068,7 +1068,7 @@ public class Xcls_WindowLeftTree : Object
                         
                                var is_shift = _this.keystate.is_shift > 0;
                                
-                               GLib.debug("shift is    %s", _this.keystate.is_shift > 0 ? "SHIFT" : "-");
+                               //GLib.debug("shift is    %s", _this.keystate.is_shift > 0 ? "SHIFT" : "-");
                                string pos; // over / before / after..
                        
                            //GLib.debug("got drag motion");
@@ -1079,7 +1079,7 @@ public class Xcls_WindowLeftTree : Object
                                try {
                                        cont.get_value(ref v);
                                } catch (GLib.Error e) {
-                                   GLib.debug("failed to get drag value");
+                                  // GLib.debug("failed to get drag value");
                                        return Gdk.DragAction.COPY;      
                                
                                }
@@ -1101,7 +1101,7 @@ public class Xcls_WindowLeftTree : Object
                             foreach(var dp in drop_on_to) {
                                str += dp;
                                }
-                               GLib.debug("droplist: %s", string.joinv(", ", str));
+                               //GLib.debug("droplist: %s", string.joinv(", ", str));
                             
                             
                            // if there are not items in the tree.. the we have to set isOver to true for anything..
@@ -1119,13 +1119,14 @@ public class Xcls_WindowLeftTree : Object
                            }
                            
                            
-                               GLib.debug("check is over");
+                       
                                 
                            // if path of source and dest are inside each other..
                            // need to add source info to drag?
                            // the fail();
                                var row = _this.view.getRowAt(x,y, out pos);
-                               
+                               //GLib.debug("check is over %d, %d, %s", (int)x,(int)y, pos);
+                       
                                if (row < 0) {
                                        this.addHighlight(null, "");    
                                        return Gdk.DragAction.COPY;
@@ -1134,20 +1135,20 @@ public class Xcls_WindowLeftTree : Object
                                
                                var node =  (JsRender.Node)tr.get_item();
                                
-                               GLib.debug("Drop over node: %s", node.fqn());
+                               //GLib.debug("Drop over node: %s", node.fqn());
                                
                        
                                if (pos == "above" || pos == "below") {
                                        if (node.parent == null) {
-                                               GLib.debug("no parent try center");
+                                               //GLib.debug("no parent try center");
                                                pos = "over";
                                        } else {
                                                 
                                                if (!drop_on_to.contains(node.parent.fqn())) {
-                                                       GLib.debug("drop on does not contain %s - try center" , node.parent.fqn());
+                                                       //GLib.debug("drop on does not contain %s - try center" , node.parent.fqn());
                                                        pos = "over";
                                                } else {
-                                                       GLib.debug("drop  contains %s - using %s" , node.parent.fqn(), pos);
+                                                       //GLib.debug("drop  contains %s - using %s" , node.parent.fqn(), pos);
                                                        if (_this.view.dragNode  != null && is_shift) {
                                                                if (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {
                                                                        GLib.debug("shift drop not self not allowed");
@@ -1167,13 +1168,13 @@ public class Xcls_WindowLeftTree : Object
                                }
                                if (pos == "over") {
                                        if (!drop_on_to.contains(node.fqn())) {
-                                               GLib.debug("drop on does not contain %s - try center" , node.fqn());
+                                               //GLib.debug("drop on does not contain %s - try center" , node.fqn());
                                                this.addHighlight(null, ""); 
                                                return is_shift ?  Gdk.DragAction.MOVE :  Gdk.DragAction.COPY;          
                                        }
                                        if (_this.view.dragNode  != null && is_shift) {
                                                if (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {
-                                                       GLib.debug("shift drop not self not allowed");
+                                                       //GLib.debug("shift drop not self not allowed");
                                                        this.addHighlight(null, "");
                                                        return Gdk.DragAction.COPY;     
                                                }
@@ -1193,11 +1194,14 @@ public class Xcls_WindowLeftTree : Object
                        });
                        this.el.drop.connect( (v, x, y) => {
                                
+                               // must get the pos before we clear the hightlihg.
+                               var pos = "";
+                               var row = _this.view.getRowAt(x,y, out pos);
                                this.addHighlight(null,"");
                         
                                var is_shift = _this.keystate.is_shift > 0;
                         
-                               var pos = "";
+                       
                                // -- get position..
                                if (this.lastDragString != v.get_string() || this.lastDragNode == null) {
                                        // still dragging same node
@@ -1209,7 +1213,10 @@ public class Xcls_WindowLeftTree : Object
                                     
                               
                            var dropNode = new JsRender.Node(); 
-                               dropNode.loadFromJsonString(v.get_string(), 1);
+                               dropNode.loadFromJsonString(v.get_string(), 2);
+                               GLib.debug("dropped node %s", dropNode.toJsonString());
+                               
+                               
                                var drop_on_to = _this.main_window.windowstate.file.palete().getDropList(dropNode.fqn());
                           
                            // if there are not items in the tree.. the we have to set isOver to true for anything..
@@ -1221,7 +1228,7 @@ public class Xcls_WindowLeftTree : Object
                                                return false;   
                                        }
                                        // add new node to top..
-                                       
+                                       GLib.debug("adding to top");
                                        
                                         var m = (GLib.ListStore) _this.model.el.model;
                                _this.main_window.windowstate.file.tree = dropNode;  
@@ -1236,8 +1243,9 @@ public class Xcls_WindowLeftTree : Object
                        
                        
                        
-                               var row = _this.view.getRowAt(x,y, out pos);
+                       
                                if (row < 0) {
+                                       GLib.debug("could not get row %d,%d, %s", (int)x,(int)y,pos);
                                        return   false; //Gdk.DragAction.COPY;
                                }
                                var tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);
@@ -1279,12 +1287,12 @@ public class Xcls_WindowLeftTree : Object
                                
                                switch(pos) {
                                        case "over":
-                                               node.appendChild(dropNode);
+                       
                                                if (is_shift && _this.view.dragNode != null) {
                                                        _this.model.selectNode(null); 
                                                        _this.view.dragNode.remove();
                                                }
-                                                       
+                                               node.appendChild(dropNode);                     
                                                dropNode.updated_count++;
                                                _this.model.selectNode(dropNode); 
                                                
@@ -1294,11 +1302,12 @@ public class Xcls_WindowLeftTree : Object
                                        case "above":
                                                GLib.debug("Above - insertBefore");
                                        
-                                               node.parent.insertBefore(dropNode, node);
+                       
                                                if (is_shift && _this.view.dragNode != null) {
                                                        _this.model.selectNode(null);                   
                                                        _this.view.dragNode.remove();
                                                }
+                                               node.parent.insertBefore(dropNode, node);                       
                                                dropNode.updated_count++;
                                                _this.model.selectNode(dropNode);                       
                                                _this.changed();
@@ -1336,7 +1345,7 @@ public class Xcls_WindowLeftTree : Object
                public void addHighlight (Gtk.Widget? w, string hl) {
                        if (this.highlightWidget != null) {
                                var ww  = this.highlightWidget;
-                               GLib.debug("clear drag from previous highlight");
+                               //GLib.debug("clear drag from previous highlight");
                                if (ww.has_css_class("drag-below")) {
                                         ww.remove_css_class("drag-below");
                                }
@@ -1348,7 +1357,7 @@ public class Xcls_WindowLeftTree : Object
                                }
                        }
                        if (w != null) {
-                               GLib.debug("add drag=%s to widget", hl);        
+                               //GLib.debug("add drag=%s to widget", hl);      
                                if (!w.has_css_class("drag-" + hl)) {
                                        w.add_css_class("drag-" + hl);
                                }
@@ -1430,7 +1439,7 @@ public class Xcls_WindowLeftTree : Object
                                    // why dup_?
                                    
                        
-                                   GLib.debug ("calling left_tree.node_selected");
+                                   GLib.debug ("calling left_tree.node_selected %s", snode.toJsonString());
                                    _this.node_selected(snode);
                                   
                                     
@@ -1447,8 +1456,11 @@ public class Xcls_WindowLeftTree : Object
                public JsRender.Node? getSelectedNode () {
                  if (this.el.selected_item == null) {
                                return null;
-                 }                             
+                 }     
+                  
+                 
                   var tr = (Gtk.TreeListRow)this.el.selected_item;
+                 
                   return (JsRender.Node)tr.get_item();
                         
                }
@@ -1716,7 +1728,7 @@ public class Xcls_WindowLeftTree : Object
                                
                        });
                        this.el.bind.connect( (listitem) => {
-                                GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
+                               // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
                                
                                //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
                                var expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();
@@ -1730,8 +1742,10 @@ public class Xcls_WindowLeftTree : Object
                                
                                var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
                                var node = (JsRender.Node) lr.get_item();
-                               
-                          GLib.debug("node is %s", node.get_type().name());
+                               if (node == null || node.fqn() == "") {
+                                       return;
+                               }
+                          //GLib.debug("node is %s", node.get_type().name());
                        // was item (1) in old layout
                        
                                
index 98fa40c..497caf2 100644 (file)
             "         ",
             "    ",
             "    } catch (Error e) {",
+            "    \tGLib.debug(\"error loading %s : %s\", f.get_uri(),e.message);",
             "        inhtml = {};",
             "    }    ",
             "    this.renderedData = js;",
             "    var fc =    FakeServerCache.factory_with_data(js_src);",
             "    this.runjs = fc.fname;",
             "    var html  = (string) inhtml;",
+            "    html = html == null ? \"\" : html; // fix null?",
+            "    ",
             "\thtml = html.replace(\"</head>\", runhtml + this.runhtml + ",
             "        \"<script type=\\\"text/javascript\\\" src=\\\"xhttp://localhost\" + fc.fname + \"\\\"></script>\" +   ",
             "          //  \"<script type=\\\"text/javascript\\\">\\n\" +",
index 6f40526..83c4804 100644 (file)
@@ -922,6 +922,7 @@ public class Xcls_WindowRooView : Object
                         
                    
                    } catch (Error e) {
+                       GLib.debug("error loading %s : %s", f.get_uri(),e.message);
                        inhtml = {};
                    }    
                    this.renderedData = js;
@@ -949,6 +950,8 @@ public class Xcls_WindowRooView : Object
                    var fc =    FakeServerCache.factory_with_data(js_src);
                    this.runjs = fc.fname;
                    var html  = (string) inhtml;
+                   html = html == null ? "" : html; // fix null?
+                   
                        html = html.replace("</head>", runhtml + this.runhtml + 
                        "<script type=\"text/javascript\" src=\"xhttp://localhost" + fc.fname + "\"></script>" +   
                          //  "<script type=\"text/javascript\">\n" +
index 485f078..cc8060b 100644 (file)
@@ -453,7 +453,7 @@ namespace JsRender {
                }
                
                bool in_undo = false;
-               protected void updateUndo()
+               public void updateUndo()
                {
                        if (this.in_undo) {
                                return;
@@ -871,9 +871,10 @@ namespace JsRender {
                        Node.uid_count = 0;
                        this.tree = new Node();
                        this.tree.loadFromJson(obj,bjs_version);
-                       this.tree.version_changed.connect(() => {
-                               this.updateUndo();
-                       });
+                       this.tree.file = this;
+                       //this.tree.version_changed.connect(() => {
+                       //      this.updateUndo();
+                       //});
                
                }
                
index 73515e9..eea58d3 100644 (file)
@@ -110,7 +110,7 @@ public class JsRender.Node : GLib.Object {
        public Gee.HashMap<int,string> line_map; // store of l:xxx or p:....  // fixme - not needed as we can store line numbers in props now.
        public Gee.ArrayList<int> node_lines; 
        public Gee.HashMap<int,Node> node_lines_map; // store of l:xxx or p:....
-       
+       public JsRender? file = null;
        
        public string node_pad = "";
        
@@ -127,10 +127,11 @@ public class JsRender.Node : GLib.Object {
                                
                        //GLib.debug("Update Node %d p%d - rev %d", this.oid, this.parent != null ? this.parent.oid : -1, value);
                        if (this.parent != null) {
-                               this.parent.updated_count++;
+                               this.parent.updated_count++; // will recurse up.
                        }  else {
-                               //GLib.debug("UNDO top node is %d", value);
-                               this.version_changed();
+                               if (this.file != null) {
+                                       this.file.updateUndo();
+                               }
                        }
                }
  
@@ -142,7 +143,7 @@ public class JsRender.Node : GLib.Object {
         
        
        
-       public signal void  version_changed();
+       //public signal void  version_changed();
        
        public Node()
        {
@@ -958,15 +959,17 @@ public class JsRender.Node : GLib.Object {
        
        public void insertChild(int pos, Node child)
        {
+               child.parent = this;
                this.items.insert(pos, child);
                this.childstore.insert(pos, child);
-               child.parent = this;
+               
        }
        public void appendChild(Node child)
        {
+               child.parent = this;
                this.items.add( child);
                this.childstore.append(child);
-               child.parent = this;
+
        }