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 @@ -9,7 +9,6 @@
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import org.osgi.framework.BundleContext;

Expand Down Expand Up @@ -53,7 +52,7 @@ public Color getColor(Display display, String key) {
final int r = Integer.parseInt(cols[0].trim());
final int g = Integer.parseInt(cols[1].trim());
final int b = Integer.parseInt(cols[2].trim());
return new Color(display, new RGB(r, g, b));
return new Color(r, g, b);
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getColor(Display display, ...) now returns new Color(r, g, b), which ignores the provided display. This can create the Color on the wrong SWT Device (or fail if there is no current display), while ResourceService pools resources by the passed-in display. Create the color on the supplied display’s UI thread (e.g., via display.syncExec) so the resource is associated with the correct device.

Suggested change
return new Color(r, g, b);
final Color[] createdColor = new Color[1];
display.syncExec(() -> createdColor[0] = new Color(display, r, g, b));
return createdColor[0];

Copilot uses AI. Check for mistakes.
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private void createTreeItemResources() {

treeItemCursor = new TreeItemCursor(getTree().getCursor(), display.getSystemCursor(SWT.CURSOR_HAND));

treeItemForeground = new TreeItemForeground(new Color(display, new RGB(0, 0, 120)),
treeItemForeground = new TreeItemForeground(new Color(new RGB(0, 0, 120)),
display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT), display.getSystemColor(SWT.COLOR_BLACK));

treeItemBackground = new TreeItemBackground(display.getSystemColor(SWT.COLOR_LIST_SELECTION),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;

public class ColorManager {

Expand All @@ -18,7 +17,7 @@ public void dispose() {
public Color getColor(RGB rgb) {
Color color = fColorTable.get(rgb);
if (color == null) {
color = new Color(Display.getCurrent(), rgb);
color = new Color(rgb);
fColorTable.put(rgb, color);
}
return color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;

import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextAttribute;
Expand All @@ -15,8 +14,8 @@

public class $javaClassPrefix$PresentationReconciler extends PresentationReconciler {

private final TextAttribute tagAttribute = new TextAttribute(new Color(Display.getCurrent(), new RGB(0,0, 255)));
private final TextAttribute headerAttribute = new TextAttribute(new Color(Display.getCurrent(), new RGB(128,128,128)));
private final TextAttribute tagAttribute = new TextAttribute(new Color(new RGB(0,0, 255)));
private final TextAttribute headerAttribute = new TextAttribute(new Color(new RGB(128,128,128)));
Comment on lines +17 to +18
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This template creates Color instances inline for TextAttribute fields but never disposes them. Generated editors will leak SWT color resources unless they explicitly dispose these colors. Prefer routing color creation through a ColorManager/ColorRegistry with a dispose() hook, or ensure the reconciler disposes the colors when the editor is disposed.

Copilot uses AI. Check for mistakes.

public $javaClassPrefix$PresentationReconciler() {
// TODO this is logic for .project file to color tags in blue. Replace with your language logic!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private void putColor(String property, RGB setting) {
return;
}
}
fColorTable.put(property, new Color(Display.getCurrent(), setting));
fColorTable.put(property, new Color(setting));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void setErrorStatus(IStatus status) {
setText(message);
setImage(findImage(status));
if (fErrorMsgAreaBackground == null) {
fErrorMsgAreaBackground = new Color(getDisplay(), ERROR_BACKGROUND_RGB);
fErrorMsgAreaBackground = new Color(ERROR_BACKGROUND_RGB);
}
setBackground(fErrorMsgAreaBackground);
Comment on lines 77 to 80
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fErrorMsgAreaBackground is created with new Color(...) but never disposed. The current dispose() implementation only nulls the reference, which will leak the OS color resource over the widget’s lifetime. Dispose the color (when non-null and not already disposed) before calling super.dispose().

Copilot uses AI. Check for mistakes.
return;
Expand Down
Loading