Undo All causes NPE
Issue #542
new
With the changes introduced in pull request #141, namely the UINotifyChangedListener
, notifications are handled with a “delay” (next UI loop). There is a race condition in certain cases causing a NPE.
Steps to reproduce:
- Open a design model with a class
- Create an attribute
- Delete the attribute
- Choose to go back to the feature model
- When asked whether you want to save, choose No
Result:
Caused by: java.lang.NullPointerException
at ca.mcgill.sel.ram.ui.views.structural.AttributeView.<init>(AttributeView.java:85)
at ca.mcgill.sel.ram.ui.views.structural.ClassifierView.addAttributeField(ClassifierView.java:184)
at ca.mcgill.sel.ram.ui.views.structural.ClassifierView.handleNotification(ClassifierView.java:495)
at ca.mcgill.sel.ram.ui.components.listeners.UINotifyChangedListener$1.run(UINotifyChangedListener.java:25)
at org.mt4j.AbstractMTApplication.runApplication(AbstractMTApplication.java:360)
Step 5 undos all the changes until the last save state is reached. Here, first the attribute is added, then removed. By the time the notification is handled, the attribute is removed from the model, meaning that it does not have a container anymore.
I assume this also causes problems with other elements, such as operations. It might be safer to suppress notifications during this task, since the UI does not have to be updated anyway.