File: NPE_null_scroll_pane

package info (click to toggle)
libjsyntaxpane-java 0.9.6~r156-7
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,424 kB
  • sloc: java: 6,108; xml: 41; sh: 14; makefile: 11
file content (26 lines) | stat: -rw-r--r-- 1,017 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Description: Avoid a NPE when the ruler is installed before the scrollPane
 This could happen by passing the content type to the JEditorPane
 constructor, ie clearly before the addition of the editor pane to a
 scroll pane.
Author: Martin Quinson
Upstream-status: Forwarded
Upstream-bug: https://code.google.com/p/jsyntaxpane/issues/detail?id=191

---
 src/main/java/jsyntaxpane/components/LineNumbersRuler.java |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: b/src/main/java/jsyntaxpane/components/LineNumbersRuler.java
===================================================================
--- a/src/main/java/jsyntaxpane/components/LineNumbersRuler.java
+++ b/src/main/java/jsyntaxpane/components/LineNumbersRuler.java
@@ -127,7 +127,8 @@
 		editor.addCaretListener(this);
 		editor.addPropertyChangeListener(this);
 		JScrollPane sp = getScrollPane(editor);
-		sp.setRowHeaderView(this);
+	   	if (sp != null)
+			sp.setRowHeaderView(this);
 		mouseListener = new MouseAdapter() {
 
 			@Override