project structure: don't recreate modifiable models during applying changes (IDEA-168208)

Previously if someone tries to access ModuleRootModel after ModuleEditor.apply is called but before the model returned by it is committed (e.g. from myFacetsConfigurator.applyEditors) a new ModifiableRootModel instance will be created from the original ModuleRootModel, thus it won't include changes made in Project Structure dialog and may contain invalid OrderEntry instances.
This commit is contained in:
nik
2017-03-28 15:26:57 +03:00
parent 40a4b22933
commit fb8c576f34
2 changed files with 13 additions and 13 deletions
@@ -318,24 +318,21 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
myGenericSettingsPanel = null;
}
finally {
myModifiableRootModel = null;
myModifiableRootModelProxy = null;
resetModifiableModel();
}
}
public ModifiableRootModel apply() throws ConfigurationException {
try {
for (ModuleConfigurationEditor editor : myEditors) {
editor.saveData();
editor.apply();
}
for (ModuleConfigurationEditor editor : myEditors) {
editor.saveData();
editor.apply();
}
return myModifiableRootModel;
}
return myModifiableRootModel;
}
finally {
myModifiableRootModel = null;
myModifiableRootModelProxy = null;
}
void resetModifiableModel() {
myModifiableRootModel = null;
myModifiableRootModelProxy = null;
}
public void canApply() throws ConfigurationException {
@@ -313,6 +313,9 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change
try {
ModifiableModelCommitter.multiCommit(models, myModuleModel);
for (ModuleEditor editor : myModuleEditors.values()) {
editor.resetModifiableModel();
}
myModuleModelCommitted = true;
myFacetsConfigurator.commitFacets();