From 89ec378d5b582e440e7ab65356905d42bc7b348c Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Thu, 28 Aug 2014 19:40:32 +0400 Subject: [PATCH] Get rid of Editor leaks in CodeStyleSettings (IDEA-95395) [CR-IC-6178] --- .../options/CodeStyleSchemesConfigurable.java | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java index bb7bf0655b27..760d17e67d24 100644 --- a/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java +++ b/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java @@ -346,34 +346,31 @@ public class CodeStyleSchemesConfigurable extends SearchableConfigurable.Parent. String displayName = myProvider.getConfigurableDisplayName(); if (displayName != null) return displayName; - return ensurePanel().getDisplayName(); // fallback for 8.0 API compatibility + return myPanel != null ? myPanel.getDisplayName() : null; // fallback for 8.0 API compatibility } @Override public String getHelpTopic() { - return ensurePanel().getHelpTopic(); - } - - private CodeStyleMainPanel ensurePanel() { - if (myPanel == null) { - myPanel = new CodeStyleMainPanel(ensureModel(), myLangSelector, myFactory); - } - return myPanel; + return myPanel != null ? myPanel.getHelpTopic() : null; } @Override public JComponent createComponent() { - return ensurePanel(); + myPanel = new CodeStyleMainPanel(ensureModel(), myLangSelector, myFactory); + return myPanel; } @Override public boolean isModified() { - boolean someSchemeModified = ensurePanel().isModified(); - if (someSchemeModified) { - myApplyCompleted = false; - myRevertCompleted = false; + if (myPanel != null) { + boolean someSchemeModified = myPanel.isModified(); + if (someSchemeModified) { + myApplyCompleted = false; + myRevertCompleted = false; + } + return someSchemeModified; } - return someSchemeModified; + return false; } @Override @@ -428,20 +425,25 @@ public class CodeStyleSchemesConfigurable extends SearchableConfigurable.Parent. } public boolean isPanelModified(CodeStyleScheme scheme) { - return ensurePanel().isModified(scheme); + return myPanel != null && myPanel.isModified(scheme); } public boolean isPanelModified() { - return ensurePanel().isModified(); + return myPanel != null && myPanel.isModified(); } public void applyPanel() throws ConfigurationException { - ensurePanel().apply(); + if (myPanel != null) { + myPanel.apply(); + } } @Override public Set processListOptions() { - return ensurePanel().processListOptions(); + if (myPanel == null) { + myPanel = new CodeStyleMainPanel(ensureModel(), myLangSelector, myFactory); + } + return myPanel.processListOptions(); } } }