@yuneta/gobj-js 7.26.28 → 7.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2154,7 +2154,8 @@
2154
2154
  if (!gobj_is_running(gobj)) {
2155
2155
  if (!(gobj.gclass.gclass_flag & gclass_flag_t.gcflag_required_start_to_play)) {
2156
2156
  log_warning(`${gobj_short_name(gobj)}: GObj playing without previous start`);
2157
- gobj_start(gobj);
2157
+ if (start_destroys_it(gobj)) return -1;
2158
+ if (!gobj.running) return -1;
2158
2159
  } else {
2159
2160
  log_error(`${gobj_short_name(gobj)}: Cannot play, start not done`);
2160
2161
  return -1;
@@ -2979,12 +2980,20 @@
2979
2980
  function gobj_change_parent(gobj, parent) {
2980
2981
  if (gobj_is_destroying(gobj)) {
2981
2982
  log_error("gobj NULL or DESTROYED");
2982
- return null;
2983
+ return -1;
2983
2984
  }
2984
2985
  if (!(parent instanceof GObj)) {
2985
2986
  log_error(`${gobj_short_name(gobj)}: gobj_change_parent() BAD TYPE of parent`);
2986
2987
  return -1;
2987
2988
  }
2989
+ if (gobj_is_destroying(parent)) {
2990
+ log_error(`${gobj_short_name(gobj)}: gobj_change_parent() parent NULL or DESTROYED`);
2991
+ return -1;
2992
+ }
2993
+ for (let p = parent; p; p = p.parent) if (p === gobj) {
2994
+ log_error(`${gobj_short_name(gobj)}: gobj_change_parent() a gobj cannot be its own ancestor: ${gobj_short_name(parent)}`);
2995
+ return -1;
2996
+ }
2988
2997
  if (gobj.parent && gobj.parent.gclass.gmt.mt_child_removed) gobj.parent.gclass.gmt.mt_child_removed(gobj.parent, gobj);
2989
2998
  if (gobj.parent) {
2990
2999
  _remove_child(gobj.parent, gobj);
@@ -7455,15 +7464,17 @@
7455
7464
  * The uuid of this node: ONE for the life of the page.
7456
7465
  *
7457
7466
  * The one the store keeps ("host_uuid"), made and written there when
7458
- * there is none. When the store cannot keep it (blocked, full, no
7459
- * localStorage, outside a browser) the one this page made, warned
7460
- * once. It goes in the node_uuid attribute of the yuno, the id of the
7467
+ * there is none. When the store cannot keep it the one this page
7468
+ * made: warned once when the store is blocked or full, silent when
7469
+ * there is no localStorage or no browser at all. It goes in the node_uuid attribute of the yuno, the id of the
7461
7470
  * identity card and the `host` of every message the client sends, so
7462
7471
  * the first answer is kept and answered again: 7.26.27 made a new
7463
7472
  * uuid on every call when the store could not keep it, and answered
7464
- * null without crypto.randomUUID().
7473
+ * null without crypto.randomUUID(). A stored value that is not a
7474
+ * uuid (a foreign or corrupt write) is replaced, with a WARNING.
7465
7475
  ************************************************************/
7466
7476
  var uuid_of_this_page = null;
7477
+ var UUID_SHAPE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
7467
7478
  function node_uuid() {
7468
7479
  if (uuid_of_this_page) return uuid_of_this_page;
7469
7480
  const store = local_store();
@@ -7479,6 +7490,10 @@
7479
7490
  uuid_of_this_page = new_uuid();
7480
7491
  return uuid_of_this_page;
7481
7492
  }
7493
+ if (uuid && !UUID_SHAPE.test(uuid)) {
7494
+ log_warning("node_uuid(): the stored host_uuid is not a uuid: a new one replaces it");
7495
+ uuid = null;
7496
+ }
7482
7497
  if (!uuid) {
7483
7498
  uuid = new_uuid();
7484
7499
  try {