Skip to content

Commit 2d64803

Browse files
committed
Prevent AIOOBE in error table
If the error checker updates the table between the click and invocation of the click event listener, selection will be cleared and click index will be -1. Checking if the index is valid before using it.
1 parent b343953 commit 2d64803

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

app/src/processing/app/ui/ErrorTable.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,25 @@ public ErrorTable(final Editor editor) {
105105
// }
106106

107107
addMouseListener(new MouseAdapter() {
108-
@Override
109-
synchronized public void mouseClicked(MouseEvent e) {
110-
try {
111-
int row = ((ErrorTable) e.getSource()).getSelectedRow();
112-
if (row >= 0 && row < getRowCount()) {
113-
Object data = getModel().getValueAt(row, DATA_COLUMN);
114-
int clickCount = e.getClickCount();
115-
if (clickCount == 1) {
116-
editor.errorTableClick(data);
117-
} else if (clickCount > 1) {
118-
editor.errorTableDoubleClick(data);
119-
}
108+
@Override
109+
synchronized public void mouseClicked(MouseEvent e) {
110+
try {
111+
int row = ((ErrorTable) e.getSource()).getSelectedRow();
112+
if (row >= 0 && row < getRowCount()) {
113+
Object data = getModel().getValueAt(row, DATA_COLUMN);
114+
int clickCount = e.getClickCount();
115+
if (clickCount == 1) {
116+
editor.errorTableClick(data);
117+
} else if (clickCount > 1) {
118+
editor.errorTableDoubleClick(data);
119+
}
120120
// editor.getErrorChecker().scrollToErrorLine(row);
121-
}
122-
} catch (Exception ex) {
123-
ex.printStackTrace();
124-
}
125-
}
126-
});
121+
}
122+
} catch (Exception ex) {
123+
ex.printStackTrace();
124+
}
125+
}
126+
});
127127

128128
/*
129129
addMouseMotionListener(new MouseMotionAdapter() {

0 commit comments

Comments
 (0)