mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix KeymapPanel leak in tests which create KeymapPanel but don't call its createComponent() method
GitOrigin-RevId: d26a718c985d143b57cd126fd0f80524a4e9e092
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4516cf5994
commit
6baeae2c50
@@ -71,7 +71,8 @@ import static com.intellij.openapi.actionSystem.impl.ActionToolbarImpl.updateAll
|
||||
public class KeymapPanel extends JPanel implements SearchableConfigurable, Configurable.NoScroll, KeymapListener, Disposable {
|
||||
private JCheckBox preferKeyPositionOverCharOption;
|
||||
|
||||
private final KeymapSchemeManager myManager = new KeymapSelector(this::currentKeymapChanged, this).getManager();
|
||||
private final KeymapSelector myKeymapSelector = new KeymapSelector(this::currentKeymapChanged);
|
||||
private final KeymapSchemeManager myManager = myKeymapSelector.getManager();
|
||||
private final ActionsTree myActionsTree = new ActionsTree();
|
||||
private FilterComponent myFilterComponent;
|
||||
private TreeExpansionMonitor myTreeExpansionMonitor;
|
||||
@@ -610,6 +611,7 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi
|
||||
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
myKeymapSelector.attachKeymapListener(this);
|
||||
ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(CHANGE_TOPIC, this);
|
||||
return this;
|
||||
}
|
||||
@@ -838,8 +840,7 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi
|
||||
}
|
||||
else {
|
||||
if (manager == null) {
|
||||
manager = new KeymapSelector(selectedKeymap -> {
|
||||
}, null).getManager();
|
||||
manager = new KeymapSelector(selectedKeymap -> { }).getManager();
|
||||
manager.reset();
|
||||
}
|
||||
mutable = manager.getMutableKeymap(selected);
|
||||
|
||||
+20
-34
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.keymap.impl.ui;
|
||||
|
||||
import com.intellij.application.options.schemes.AbstractSchemeActions;
|
||||
@@ -46,30 +32,30 @@ final class KeymapSelector extends SimpleSchemesPanel<KeymapScheme> {
|
||||
private boolean messageShown;
|
||||
private boolean internal;
|
||||
|
||||
KeymapSelector(Consumer<? super Keymap> consumer, @Nullable Disposable parentDisposable) {
|
||||
KeymapSelector(Consumer<? super Keymap> consumer) {
|
||||
super(0);
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
if (parentDisposable != null) {
|
||||
ApplicationManager.getApplication().getMessageBus().connect(parentDisposable).subscribe(KeymapManagerListener.TOPIC, new KeymapManagerListener() {
|
||||
@Override
|
||||
public void keymapAdded(@NotNull Keymap keymap) {
|
||||
manager.handleKeymapAdded(keymap);
|
||||
resetSchemes(manager.getSchemes());
|
||||
}
|
||||
void attachKeymapListener(@NotNull Disposable parentDisposable) {
|
||||
ApplicationManager.getApplication().getMessageBus().connect(parentDisposable).subscribe(KeymapManagerListener.TOPIC, new KeymapManagerListener() {
|
||||
@Override
|
||||
public void keymapAdded(@NotNull Keymap keymap) {
|
||||
manager.handleKeymapAdded(keymap);
|
||||
resetSchemes(manager.getSchemes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keymapRemoved(@NotNull Keymap keymap) {
|
||||
manager.handleKeymapRemoved(keymap);
|
||||
resetSchemes(manager.getSchemes());
|
||||
}
|
||||
@Override
|
||||
public void keymapRemoved(@NotNull Keymap keymap) {
|
||||
manager.handleKeymapRemoved(keymap);
|
||||
resetSchemes(manager.getSchemes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activeKeymapChanged(@Nullable Keymap keymap) {
|
||||
manager.handleActiveKeymapChanged(keymap);
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void activeKeymapChanged(@Nullable Keymap keymap) {
|
||||
manager.handleActiveKeymapChanged(keymap);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user