From b8e768869d5b8145d71c3841b4f8cd0b4b57fd1b Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Mon, 17 Jun 2019 17:07:15 +0300 Subject: [PATCH] [vcs-log] unsubscribe from vcs configuration changes before project log dispose GitOrigin-RevId: fb6196ea063e3b6a4a24d87605d72aa41c8bdd32 --- .../com/intellij/vcs/log/impl/VcsProjectLog.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsProjectLog.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsProjectLog.java index 286ef136533c..c63eb9837ef1 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsProjectLog.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsProjectLog.java @@ -24,11 +24,11 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupActivity; import com.intellij.openapi.ui.MessageType; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.vcs.ProjectLevelVcsManager; import com.intellij.openapi.vcs.VcsRoot; import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier; import com.intellij.util.messages.MessageBus; -import com.intellij.util.messages.MessageBusConnection; import com.intellij.util.messages.Topic; import com.intellij.util.ui.UIUtil; import com.intellij.vcs.log.data.VcsLogData; @@ -50,8 +50,8 @@ public class VcsProjectLog implements Disposable { @NotNull private final VcsLogTabsProperties myUiProperties; @NotNull private final VcsLogTabsManager myTabsManager; - @NotNull - private final LazyVcsLogManager myLogManager = new LazyVcsLogManager(); + @NotNull private final LazyVcsLogManager myLogManager = new LazyVcsLogManager(); + @NotNull private final Disposable myMappingChangesDisposable = Disposer.newDisposable(); private int myRecreatedLogCount = 0; public VcsProjectLog(@NotNull Project project, @@ -61,6 +61,12 @@ public class VcsProjectLog implements Disposable { myMessageBus = messageBus; myUiProperties = uiProperties; myTabsManager = new VcsLogTabsManager(project, messageBus, uiProperties, this); + + Disposer.register(this, myMappingChangesDisposable); + } + + private void subscribeToMappingsChanges() { + myMessageBus.connect(myMappingChangesDisposable).subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, this::recreateLog); } @Nullable @@ -209,8 +215,7 @@ public class VcsProjectLog implements Disposable { VcsProjectLog projectLog = getInstance(project); ApplicationManager.getApplication().executeOnPooledThread(() -> { - MessageBusConnection connection = project.getMessageBus().connect(project); - connection.subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, projectLog::recreateLog); + projectLog.subscribeToMappingsChanges(); if (projectLog.hasDvcsRoots()) { projectLog.createLog(false); }