Open PiispaH opened 9 months ago
Nice one @PiispaH - I think another option is not to error out if there is nothing to commit. I'm not sure why we do it - it may be very old legacy. Essentially, the commit action should make sure that the contents of the mapping are in synch with the contents of the DB. If there are no changes, then the above holds trivially so it's fine. What do you think? @jkiviluo @soininen ?
I think it is OK to error at "nothing to commit" on spinedb_api level because that might be interesting information (has helped me to find bugs in client code) but we could just ignore the error in DB editor.
One thing though: it might be confusing if user gets prompted for a commit message and the message never ends in the database so maybe we want to inform the user after all that nothing was committed. It need not be an error message, though.
Having an empty db adding an item like entity class and then deleting it immediately causes the db to be in a state where there is nothing to commit but the undo stack isn't clean either. When the user then tries to close the editor, they get prompted to commit the "changes". If they choose to commit before exiting, an error occurs because there is indeed nothing to commit.
Should / is it possible to check if the undo stack has "traced back to the start" meaning that no changes have actually been made and in that case mark the database as not dirty? This would allow the user to still undo the changes but also close the editor without being prompted to commit non existing changes.