Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2020-03-24 07:26:27 +0000
committerThomas Wolf2020-03-24 07:28:30 +0000
commit467ab6e50409e63c34e24c9f3e60fc0d662344b4 (patch)
tree05b296ff8521d923d2df42e77536ebae19cbb212
parentbb8f9c60f8b715fbdab551ae195f95f51190e2c6 (diff)
downloadegit-stable-5.7.tar.gz
egit-stable-5.7.tar.xz
egit-stable-5.7.zip
[repo view] Avoid potential NPE in label providerstable-5.7
Don't set a style for the paths of repositories or working trees if no styles were set originally. Bug: 561377 Change-Id: I0f02d8cbcdec17be844896c3ae2234b455a71f20 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryTreeNodeLabelProvider.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryTreeNodeLabelProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryTreeNodeLabelProvider.java
index 458769d15b..d381aac133 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryTreeNodeLabelProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryTreeNodeLabelProvider.java
@@ -175,15 +175,18 @@ public class RepositoryTreeNodeLabelProvider
} else if (element instanceof WorkingDirNode) {
newText += repository.getWorkTree().getAbsolutePath();
}
- StyleRange style = new StyleRange();
- style.start = textAfter.length();
- style.length = newText.length();
- StyledString.QUALIFIER_STYLER.applyStyles(style);
- StyleRange[] newRanges = new StyleRange[rangesAfter.length + 1];
- System.arraycopy(rangesAfter, 0, newRanges, 0, rangesAfter.length);
- newRanges[newRanges.length - 1] = style;
cell.setText(textAfter + newText);
- cell.setStyleRanges(newRanges);
+ if (rangesAfter != null) {
+ StyleRange style = new StyleRange();
+ style.start = textAfter.length();
+ style.length = newText.length();
+ StyledString.QUALIFIER_STYLER.applyStyles(style);
+ StyleRange[] newRanges = new StyleRange[rangesAfter.length + 1];
+ System.arraycopy(rangesAfter, 0, newRanges, 0,
+ rangesAfter.length);
+ newRanges[newRanges.length - 1] = style;
+ cell.setStyleRanges(newRanges);
+ }
} else {
updater.accept(cell);
}

Back to the top