Asset löschen lässt Verweise auf die mitgelöschten Objekte stehen #286

Closed
opened 2026-09-30 22:37:00 +02:00 by meleki · 1 comment
Owner

Aus #269 (dort gefunden, nicht behoben).

Befund

  • DeleteAssetCommand (src/core/commands/assetCommands.ts:217) löscht mit einem Asset per Kaskade alle platzierten Objekte, die es verwenden, samt ihren Kindern, in Szenen und in Container-Templates (removeSubtrees, Zeile 245).
  • Verweise auf diese Objekte leert es nicht. Zeigt eine Object-Variable (auch ein Object-Feld oder Object-Item) auf ein so gelöschtes Objekt, bleibt der Verweis stehen, der Inspector zeigt (missing), und im Spiel liest sich der Wert als null.
  • Das gilt auch, wenn das gelöschte Asset ein Container ist: Seine Platzierungen verschwinden, Verweise auf deren Inhalt bleiben stehen.
  • Beim Entfernen einzelner Objekte passiert das seit #269 nicht mehr: RemoveSceneObjectsCommand merkt sich mit shownObjectIds, welche Objekte jeder Halter zeigt, und leert danach mit dropReferencesToGone alles, was nicht mehr aufgelöst wird.

Zu bauen (Vorschlag)

  • In DeleteAssetCommand.execute vor der Kaskade shownObjectIds(project) festhalten und nach dem Entfernen des Assets dropReferencesToGone(project, before, recorder) aufrufen. Der Recorder kommt ins undo, damit ein Undo alle Verweise zurückbringt.
  • Das sind wenige Zeilen, die Regel selbst ist in #269 schon gebaut und getestet.

Tests (Vorschlag)

  • Unit: Ein Objekt zeigt auf eine Platzierung eines Sprite-Assets, das Asset wird gelöscht. Der Verweis ist danach leer, und ein Undo stellt Asset, Objekt und Verweis wieder her. Derselbe Fall mit einem Container-Asset und einem Verweis auf dessen Inhalt.
  • e2e 57 um einen Block erweitern: Asset im Asset-Browser löschen, danach zeigt die Zeile None statt (missing).
Aus #269 (dort gefunden, nicht behoben). ## Befund - `DeleteAssetCommand` (`src/core/commands/assetCommands.ts:217`) löscht mit einem Asset per Kaskade alle platzierten Objekte, die es verwenden, samt ihren Kindern, in Szenen und in Container-Templates (`removeSubtrees`, Zeile 245). - Verweise auf diese Objekte leert es nicht. Zeigt eine Object-Variable (auch ein Object-Feld oder Object-Item) auf ein so gelöschtes Objekt, bleibt der Verweis stehen, der Inspector zeigt `(missing)`, und im Spiel liest sich der Wert als `null`. - Das gilt auch, wenn das gelöschte Asset ein Container ist: Seine Platzierungen verschwinden, Verweise auf deren Inhalt bleiben stehen. - Beim Entfernen einzelner Objekte passiert das seit #269 nicht mehr: `RemoveSceneObjectsCommand` merkt sich mit `shownObjectIds`, welche Objekte jeder Halter zeigt, und leert danach mit `dropReferencesToGone` alles, was nicht mehr aufgelöst wird. ## Zu bauen (Vorschlag) - In `DeleteAssetCommand.execute` vor der Kaskade `shownObjectIds(project)` festhalten und nach dem Entfernen des Assets `dropReferencesToGone(project, before, recorder)` aufrufen. Der `Recorder` kommt ins `undo`, damit ein Undo alle Verweise zurückbringt. - Das sind wenige Zeilen, die Regel selbst ist in #269 schon gebaut und getestet. ## Tests (Vorschlag) - Unit: Ein Objekt zeigt auf eine Platzierung eines Sprite-Assets, das Asset wird gelöscht. Der Verweis ist danach leer, und ein Undo stellt Asset, Objekt und Verweis wieder her. Derselbe Fall mit einem Container-Asset und einem Verweis auf dessen Inhalt. - e2e 57 um einen Block erweitern: Asset im Asset-Browser löschen, danach zeigt die Zeile `None` statt `(missing)`.
admin added this to the Development project 2026-09-30 22:38:43 +02:00
admin moved this to Next in Development on 2026-09-30 22:38:44 +02:00
Author
Owner

Done in 5e21d47 (together with #285), wiki 12a2b16 (Behaviors, Containers, Development).

What changes

  • Delete asset now clears every reference to an object it takes along: its placements in scenes and container templates and everything parented below them. For a container asset that includes the content of its placements.
  • The row then shows None instead of (missing). One undo brings the asset, the objects and the references back.

Under the hood

  • Built as proposed. DeleteAssetCommand (src/core/commands/assetCommands.ts) records with shownObjectIds which objects every holder shows before the cascade, and calls dropReferencesToGone after it. Both come from #269.
  • The cleared references go through a Recorder of the command, and undo reverts it before the objects come back.

Tests (on melektaus-atx)

gate                    198 files, 2882 tests, CHECK EXIT 0 (2873 + 9)
unit object-references  26 passed (17 + 9)
e2e 1-17,57             ALL PASSED - 566 checks (57: +57i, +57j)
  • 57j deletes "Inner 57" through the context menu in the asset list. The reference is empty afterwards, the row shows None, and undo brings it back.
  • The unit counter-checks work, bent in a container copy. The numbers above cover #285 as well, both issues share the test file.
  • The browser counter-check works too: without the new call 57j shows (missing).
  • Screenshot checked: target shows None, "Inner 57" is gone from the asset list.
  • The e2e total of 1609 is computed (1607 + 2). CI is still switched off, so there is no run for 5e21d47.
Done in `5e21d47` (together with #285), wiki `12a2b16` (*Behaviors*, *Containers*, *Development*). **What changes** - *Delete asset* now clears every reference to an object it takes along: its placements in scenes and container templates and everything parented below them. For a container asset that includes the content of its placements. - The row then shows **None** instead of `(missing)`. One undo brings the asset, the objects and the references back. **Under the hood** - Built as proposed. `DeleteAssetCommand` (`src/core/commands/assetCommands.ts`) records with `shownObjectIds` which objects every holder shows before the cascade, and calls `dropReferencesToGone` after it. Both come from #269. - The cleared references go through a `Recorder` of the command, and `undo` reverts it before the objects come back. **Tests** (on `melektaus-atx`) ``` gate 198 files, 2882 tests, CHECK EXIT 0 (2873 + 9) unit object-references 26 passed (17 + 9) e2e 1-17,57 ALL PASSED - 566 checks (57: +57i, +57j) ``` - **57j** deletes "Inner 57" through the context menu in the asset list. The reference is empty afterwards, the row shows `None`, and undo brings it back. - The unit counter-checks work, bent in a container copy. The numbers above cover #285 as well, both issues share the test file. - The browser counter-check works too: without the new call 57j shows `(missing)`. - Screenshot checked: *target* shows None, "Inner 57" is gone from the asset list. - The e2e total of 1609 is computed (1607 + 2). CI is still switched off, so there is no run for `5e21d47`.
admin moved this to Done in Development on 2026-10-01 07:30:22 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: meleki/feuerwerk#286