From c490c67db1bd5c195370b716ed21303aee3d5ef3 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 13 Jun 2019 13:21:41 +0100 Subject: [PATCH] git: protect from the case when the CompareInfo has not been set to the panel yet GitOrigin-RevId: 0c69bc201857e85b60a92a52665ed6167a6e3aa6 --- .../dvcs/ui/CompareBranchesDiffPanel.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/ui/CompareBranchesDiffPanel.java b/platform/dvcs-impl/src/com/intellij/dvcs/ui/CompareBranchesDiffPanel.java index b5df23754f5e..cb6db6f4b1e5 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/ui/CompareBranchesDiffPanel.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/CompareBranchesDiffPanel.java @@ -42,6 +42,7 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.CalledInAwt; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.event.HyperlinkEvent; @@ -57,7 +58,7 @@ public class CompareBranchesDiffPanel extends JPanel { private final String myCurrentBranchName; private final DvcsCompareSettings myVcsSettings; - private CommitCompareInfo myCompareInfo; + @Nullable private CommitCompareInfo myCompareInfo; private final JEditorPane myLabel; private final MyChangesBrowser myChangesBrowser; @@ -106,11 +107,13 @@ public class CompareBranchesDiffPanel extends JPanel { } private void refreshView() { - boolean swapSides = myVcsSettings.shouldSwapSidesInCompareBranches(); - updateLabelText(); - List diff = myCompareInfo.getTotalDiff(); - if (swapSides) diff = DvcsBranchUtil.swapRevisions(diff); - myChangesBrowser.setChangesToDisplay(diff); + if (myCompareInfo != null) { + boolean swapSides = myVcsSettings.shouldSwapSidesInCompareBranches(); + updateLabelText(); + List diff = myCompareInfo.getTotalDiff(); + if (swapSides) diff = DvcsBranchUtil.swapRevisions(diff); + myChangesBrowser.setChangesToDisplay(diff); + } } private void updateLabelText() { @@ -188,7 +191,9 @@ public class CompareBranchesDiffPanel extends JPanel { @Override public void run(@NotNull ProgressIndicator indicator) { try { - ((LocalCommitCompareInfo)myCompareInfo).copyChangesFromBranch(changes, swapSides); + if (myCompareInfo != null) { + ((LocalCommitCompareInfo)myCompareInfo).copyChangesFromBranch(changes, swapSides); + } } catch (VcsException err) { ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog(myProject, err.getMessage(), "Can't Copy Changes"));