[settings] IJPL-249562 don't call isModified() before createComponent() in non-modal Settings

isModifiedSafely() was guarding against exceptions thrown by uninitialized configurables,
but the real fix is to not call isModified() at all when createComponent() hasn't been called yet.
Made isModifiedSafely() an instance method and added an editor.getContent(configurable) != null
guard inside it — returns null early if the configurable was never displayed.


(cherry picked from commit ce2ee379a3cef595ee8c77fbbe6d7ae368d9a7de)

IJ-CR-217470

GitOrigin-RevId: dc3f5d0bc06e6416c1c2afa31371ae14ffef5b90
This commit is contained in:
Aleksandra Olemskaia
2026-08-07 13:34:31 +00:00
committed by intellij-monorepo-bot
parent e641f7bffa
commit 03ea4d73b1
@@ -655,12 +655,14 @@ public final class SettingsEditor extends AbstractEditor implements UiDataProvid
/**
* Calls {@link Configurable#isModified()} on {@code configurable} and returns the result,
* or {@code null} if the call throws (with a warning logged).
* Some configurables throw before {@link Configurable#createComponent()} has been called —
* e.g. {@code CustomizationConfigurable} NPEs on a null panel, and
* {@code FileEncodingConfigurable} throws {@link AssertionError}.
* or {@code null} if {@link Configurable#createComponent()} has not been called yet
* (i.e. the configurable was never displayed) or if the call throws (with a warning logged).
*/
private static @Nullable Boolean isModifiedSafely(@NotNull Configurable configurable) {
private @Nullable Boolean isModifiedSafely(@NotNull Configurable configurable) {
if (editor.getContent(configurable) == null) {
LOG.debug("Configurable " + configurable.getDisplayName() + " was never displayed");
return null;
}
try {
return configurable.isModified();
}