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