Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,15 @@ private void createErrorMessageOnEditor()

// Apply bold style to default system font
FontDescriptor boldFontDescriptor = FontDescriptor.createFrom(title.getFont()).setStyle(SWT.BOLD);
title.setFont(boldFontDescriptor.createFont(parent.getDisplay()));
Font boldFont = boldFontDescriptor.createFont(parent.getDisplay());
title.setFont(boldFont);

title.addDisposeListener(e -> {
if (boldFont != null && !boldFont.isDisposed())
{
boldFont.dispose();
}
});

// Subtext explanation
Label explanation = new Label(parent, SWT.CENTER | SWT.WRAP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ public void createPartControl(Composite parent, IFile file, String targetName)

private void plotCharts()
{
if (chartComp == null || chartComp.isDisposed())
{
return;
}

for (var child : chartComp.getChildren())
child.dispose();

Expand Down Expand Up @@ -310,6 +315,12 @@ private void displayChartAsImage(Composite parent, JFreeChart chart, int width,
Image swtImg = new Image(parent.getDisplay(), imgData);
Label imgLabel = new Label(parent, SWT.NONE);
imgLabel.setImage(swtImg);
imgLabel.addDisposeListener(e -> {
if (swtImg != null && !swtImg.isDisposed())
{
swtImg.dispose();
}
});
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
*******************************************************************************/
package com.espressif.idf.ui.size;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IFile;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.TableEditor;
Expand Down Expand Up @@ -35,6 +38,7 @@ public class IDFSizeOverviewComposite
private Table table;
private JSONObject overviewJson;
private Font boldFont;
private List<TableEditor> tableEditors = new ArrayList<>();

private enum MemoryUnit
{
Expand Down Expand Up @@ -113,10 +117,28 @@ public void createPartControl(Composite parent, IFile file, String targetName)
// Bold header
Font headerFont = applyBold(table.getFont());
table.setFont(headerFont);
parent.addDisposeListener(e -> {
if (boldFont != null && !boldFont.isDisposed())
{
boldFont.dispose();
}
});
}

private void populateTable()
{
if (table == null || table.isDisposed()) return;

for (TableEditor editor : tableEditors)
{
if (editor.getEditor() != null && !editor.getEditor().isDisposed())
{
editor.getEditor().dispose();
}
editor.dispose();
}
tableEditors.clear();

table.removeAll();

// Defensive check: Handle unexpected empty data gracefully to prevent UI crash.
Expand Down Expand Up @@ -175,6 +197,7 @@ private void createProgressBar(int rowIndex, long used, long total)
return;

TableEditor editor = new TableEditor(table);
tableEditors.add(editor);
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.horizontalAlignment = SWT.FILL;
Expand Down
Loading