Skip to content

Commit d828f2c

Browse files
committed
Fixed a memory leak in table with buttons
1 parent 0eed497 commit d828f2c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/JavaTableWrapper_20150312/JavaTableWrapper/+uiextras/+jTable/Table.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,17 @@ function delete(obj)
363363
delete(obj.Container)
364364
end
365365

366+
% Loop on each column
367+
NumCol = obj.JTableModel.getColumnCount();
368+
for idx = 1:NumCol
369+
jColumn = obj.JTable.getColumnModel().getColumn(idx-1);
370+
editor = jColumn.getCellEditor();
371+
if ~isempty(editor)
372+
editor = handle(editor, 'CallbackProperties');
373+
set(editor, 'EditingCanceledCallback', []);
374+
end
375+
end
376+
366377
% Remove references to the java objects
367378
obj.JTable = [];
368379
obj.JTableModel = [];

lib/JavaTableWrapper_20150312/JavaTableWrapper/+uiextras/+jTable/TableRenderers.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function defineFormats(obj)
4242
obj.Formats = {
4343
'' javax.swing.table.DefaultTableCellRenderer []
4444
'boolean' com.jidesoft.grid.BooleanCheckBoxCellRenderer com.jidesoft.grid.BooleanCheckBoxCellEditor
45-
'button' [] []
45+
'button' UIExtrasTable.MButtonTableCellEditorRenderer []
4646
'integer' com.mathworks.consulting.swing.table.NumberCellRenderer('#,##0') com.jidesoft.grid.DoubleCellEditor
4747
'float' com.jidesoft.grid.NumberCellRenderer com.jidesoft.grid.DoubleCellEditor
4848
'bank' com.mathworks.consulting.swing.table.NumberCellRenderer('#,##0.00') com.jidesoft.grid.DoubleCellEditor
@@ -131,7 +131,6 @@ function defineFormats(obj)
131131
Editor = javaObject(EditorType);
132132
Editor = handle(Editor, 'CallbackProperties');
133133
set(Editor, 'EditingCanceledCallback', data);
134-
Renderer = Editor;
135134

136135
case 'popup'
137136
try

0 commit comments

Comments
 (0)