Fix NPE after editing and not saving (close #10164) (rebased onto develop)



This is the same as gh-608 but rebased onto develop.

----

Fix NPE
To test follow ticket's description https://trac.openmicroscopy.org.uk/ome/ticket/10164