Skip to content

Commit 398f97e

Browse files
committed
PDFBOX-5660: refactor, avoid leaking this in constructor
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1934038 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3ac0a04 commit 398f97e

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamTextView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ private void initUI(StyledDocument document)
6565
textPane.addMouseMotionListener(this);
6666
textPane.setFont(new Font("monospaced", Font.PLAIN, 13));
6767
searcher = new Searcher(textPane);
68+
searcher.init();
6869

6970
JScrollPane scrollPane = new JScrollPane(textPane);
7071

debugger/src/main/java/org/apache/pdfbox/debugger/ui/textsearcher/Searcher.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class Searcher implements DocumentListener, ChangeListener, ComponentList
5252
private static final Highlighter.HighlightPainter SELECTION_PAINTER =
5353
new DefaultHighlighter.DefaultHighlightPainter(new Color(109, 216, 26));
5454
private final SearchEngine searchEngine;
55-
private final SearchPanel searchPanel;
55+
private SearchPanel searchPanel;
5656
private final JTextComponent textComponent;
5757
private int totalMatch = 0;
5858
private int currentMatch = -1;
@@ -97,13 +97,21 @@ public void actionPerformed(ActionEvent actionEvent)
9797
public Searcher(JTextComponent textComponent)
9898
{
9999
this.textComponent = textComponent;
100-
searchPanel = new SearchPanel(this, this, this, nextAction, previousAction);
101100
searchEngine = new SearchEngine(textComponent, PAINTER);
102101

103102
nextAction.setEnabled(false);
104103
previousAction.setEnabled(false);
105104
}
106105

106+
/**
107+
* Initialization, to be called immediately after construction.
108+
*/
109+
public void init()
110+
{
111+
searchPanel = new SearchPanel(this, this, this, nextAction, previousAction);
112+
}
113+
114+
107115
public JPanel getSearchPanel()
108116
{
109117
return searchPanel.getPanel();

0 commit comments

Comments
 (0)