Memory Map: ensure columns exist on initialization

The Memory Map plugin configures the maximum and minimum size of some of
the columns.

This initialization does not take into account that a user is able to
hide columns, which results in a null pointer exception.

This commit checks that these objects are not null before configuring
them.

Fixes: f4b89fd26c ("GP-4984 - Fixed row selection while using the filter; updated columns to be resizable")
This commit is contained in:
XeR 2025-03-04 12:15:00 -01:00
parent f1dcb64e22
commit c7336e8d19

View file

@ -473,41 +473,55 @@ class MemoryMapProvider extends ComponentProviderAdapter {
TableColumn column = table.getColumn(MemoryMapModel.READ_COL); TableColumn column = table.getColumn(MemoryMapModel.READ_COL);
int width = 25; int width = 25;
int maxWidth = resizable ? Integer.MAX_VALUE : width; int maxWidth = resizable ? Integer.MAX_VALUE : width;
column.setMaxWidth(maxWidth); if (column != null) {
column.setMinWidth(width); column.setMaxWidth(maxWidth);
column.setResizable(resizable); column.setMinWidth(width);
column.setResizable(resizable);
}
column = table.getColumn(MemoryMapModel.WRITE_COL); column = table.getColumn(MemoryMapModel.WRITE_COL);
column.setMaxWidth(maxWidth); if (column != null) {
column.setMinWidth(width); column.setMaxWidth(maxWidth);
column.setResizable(resizable); column.setMinWidth(width);
column.setResizable(resizable);
}
column = table.getColumn(MemoryMapModel.EXECUTE_COL); column = table.getColumn(MemoryMapModel.EXECUTE_COL);
column.setMaxWidth(maxWidth); if (column != null) {
column.setMinWidth(width); column.setMaxWidth(maxWidth);
column.setResizable(resizable); column.setMinWidth(width);
column.setResizable(resizable);
}
column = table.getColumn(MemoryMapModel.VOLATILE_COL); column = table.getColumn(MemoryMapModel.VOLATILE_COL);
width = 65; width = 65;
maxWidth = resizable ? Integer.MAX_VALUE : width; maxWidth = resizable ? Integer.MAX_VALUE : width;
column.setMaxWidth(maxWidth); if (column != null) {
column.setMinWidth(width); column.setMaxWidth(maxWidth);
column.setResizable(resizable); column.setMinWidth(width);
column.setResizable(resizable);
}
column = table.getColumn(MemoryMapModel.ARTIFICIAL_COL); column = table.getColumn(MemoryMapModel.ARTIFICIAL_COL);
column.setMaxWidth(maxWidth); if (column != null) {
column.setMinWidth(width); column.setMaxWidth(maxWidth);
column.setResizable(resizable); column.setMinWidth(width);
column.setResizable(resizable);
}
column = table.getColumn(MemoryMapModel.BLOCK_TYPE_COL); column = table.getColumn(MemoryMapModel.BLOCK_TYPE_COL);
width = 25; width = 25;
maxWidth = resizable ? Integer.MAX_VALUE : width; maxWidth = resizable ? Integer.MAX_VALUE : width;
column.setMinWidth(width); if (column != null) {
column.setMinWidth(width);
}
column = table.getColumn(MemoryMapModel.INIT_COL); column = table.getColumn(MemoryMapModel.INIT_COL);
column.setMaxWidth(maxWidth); if (column != null) {
column.setMinWidth(width); column.setMaxWidth(maxWidth);
column.setResizable(resizable); column.setMinWidth(width);
column.setResizable(resizable);
}
} }