@yuneta/gobj-js 7.26.28 → 7.26.29

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