Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undoing a remove operation after commit does not update Database editor's views #2228

Closed
soininen opened this issue Aug 2, 2023 · 0 comments · Fixed by #2234
Closed

Undoing a remove operation after commit does not update Database editor's views #2228

soininen opened this issue Aug 2, 2023 · 0 comments · Fixed by #2234
Assignees
Labels
bug Something isn't working
Milestone

Comments

@soininen
Copy link
Contributor

soininen commented Aug 2, 2023

Steps to reproduce in Database editor:

  1. Remove an object which is used in relationships
  2. Commit changes
  3. Undo

The removed object and the removed relationships do not reappear in the corresponding tree views and the editor is left in an inconsistent state that may lead to crash if it is used for further modifications. Committing the undo action will add the object back to the database but not the relationships.

@soininen soininen added the bug Something isn't working label Aug 2, 2023
@soininen soininen added this to the V0.7 milestone Aug 2, 2023
@soininen soininen self-assigned this Aug 2, 2023
soininen added a commit to spine-tools/Spine-Database-API that referenced this issue Aug 4, 2023
The field needs to be accessed from outside.

Re spine-tools/Spine-Toolbox#2228
soininen added a commit to spine-tools/Spine-Database-API that referenced this issue Aug 4, 2023
There may be items that are marked both as removed and to-be-removed
when undoing remove actions.

Re spine-tools/Spine-Toolbox#2228
soininen added a commit to spine-tools/Spine-Database-API that referenced this issue Aug 4, 2023
Toolbox needs to know which items were removed when removing them
in cascade to be able to fully undo the removal.

Re spine-tools/Spine-Toolbox#2228
soininen added a commit to spine-tools/Spine-Database-API that referenced this issue Aug 4, 2023
soininen added a commit that referenced this issue Aug 4, 2023
No functional changes intended.

Re #2228
soininen added a commit that referenced this issue Aug 4, 2023
Committing changes in Database editor does two things that were not
taken into account when undoing commands that removed items:

- The removed items were replaced in the database cache which made
  them distinct from the items stored in the undo command
- readd/update/remove callbacks from the new items were removed
  which prevented fetch parents from being notified that the items
  were readded

On readd, SpineDBWorker now gets the real cache item to work with.
It also rebinds the callbacks if necessary before actually readding
the item back.

Re #2228
soininen added a commit that referenced this issue Aug 4, 2023
Database items are physically gone from the database after committing,
so RemoveItemsCommand needs to know all removed items and their types,
not just the one user selected for removal. This information is now
propagated to RemoveItemsCommand from spinedb_api upon commit.

Re #2228
soininen added a commit that referenced this issue Aug 4, 2023
AddItemsCommand should not readd items in cascade when redoing.
This fixes the command adding items that were not originally
added when the command was created.

Re #2228
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant