From 74ddf35d02f5a77a5b4f29626cc56e67077a9c2a Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Tue, 12 May 2015 16:54:40 +0300 Subject: [PATCH] [vcs-log] try to prevent index out of bounds from completely breaking the log --- .../intellij/vcs/log/ui/frame/VcsLogGraphTable.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java index aababb1fa7b9..58f375df7c69 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java @@ -18,6 +18,7 @@ package com.intellij.vcs.log.ui.frame; import com.intellij.icons.AllIcons; import com.intellij.ide.CopyProvider; import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.ide.CopyPasteManager; import com.intellij.openapi.util.Couple; import com.intellij.openapi.util.Pair; @@ -69,6 +70,7 @@ import java.util.*; import java.util.List; public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, CopyProvider { + private static final Logger LOG = Logger.getInstance(VcsLogGraphTable.class); public static final int ROOT_INDICATOR_COLORED_WIDTH = 8; public static final int ROOT_INDICATOR_WHITE_WIDTH = 5; @@ -336,9 +338,16 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C } private VcsLogHighlighter.VcsCommitStyle getStyle(int row, int column, String text, boolean hasFocus, final boolean selected) { - final RowInfo rowInfo = myDataPack.getVisibleGraph().getRowInfo(row); - Component dummyRendererComponent = myDummyRenderer.getTableCellRendererComponent(this, text, selected, hasFocus, row, column); + + VisibleGraph visibleGraph = myDataPack.getVisibleGraph(); + if (row < 0 || row >= visibleGraph.getVisibleCommitCount()) { + LOG.error("Visible graph has " + visibleGraph.getVisibleCommitCount() + " commits, yet we want row " + row); + return VcsCommitStyleFactory.createStyle(dummyRendererComponent.getForeground(), dummyRendererComponent.getBackground()); + } + + final RowInfo rowInfo = visibleGraph.getRowInfo(row); + VcsLogHighlighter.VcsCommitStyle defaultStyle = VcsCommitStyleFactory .createStyle(rowInfo.getRowType() == RowType.UNMATCHED ? JBColor.GRAY : dummyRendererComponent.getForeground(), dummyRendererComponent.getBackground());