Skip to content

Commit afc419b

Browse files
vogellaakurtakov
authored andcommitted
Remove dispose call for Colors in AntPreviewerUpdater
According to the Javadoc on Colors: * Colors do not need to be disposed, however to maintain compatibility * with older code, disposing a Color is not an error.
1 parent 2177bdf commit afc419b

File tree

1 file changed

+0
-37
lines changed

1 file changed

+0
-37
lines changed

ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreviewerUpdater.java

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -122,43 +122,27 @@ protected void initializeViewerColors(ISourceViewer viewer, IPreferenceStore sto
122122
: createColor(store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
123123
styledText.setForeground(color);
124124

125-
if (fForegroundColor != null) {
126-
fForegroundColor.dispose();
127-
}
128-
129125
fForegroundColor = color;
130126

131127
// ---------- background color ----------------------
132128
color = store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? null
133129
: createColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
134130
styledText.setBackground(color);
135131

136-
if (fBackgroundColor != null) {
137-
fBackgroundColor.dispose();
138-
}
139-
140132
fBackgroundColor = color;
141133

142134
// ----------- selection foreground color --------------------
143135
color = store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT) ? null
144136
: createColor(store, AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND, styledText.getDisplay());
145137
styledText.setSelectionForeground(color);
146138

147-
if (fSelectionForegroundColor != null) {
148-
fSelectionForegroundColor.dispose();
149-
}
150-
151139
fSelectionForegroundColor = color;
152140

153141
// ---------- selection background color ----------------------
154142
color = store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT) ? null
155143
: createColor(store, AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND, styledText.getDisplay());
156144
styledText.setSelectionBackground(color);
157145

158-
if (fSelectionBackgroundColor != null) {
159-
fSelectionBackgroundColor.dispose();
160-
}
161-
162146
fSelectionBackgroundColor = color;
163147
}
164148

@@ -192,25 +176,4 @@ private Color createColor(IPreferenceStore store, String key, Display display) {
192176
return null;
193177
}
194178

195-
public void dispose() {
196-
if (fForegroundColor != null) {
197-
fForegroundColor.dispose();
198-
fForegroundColor = null;
199-
}
200-
201-
if (fBackgroundColor != null) {
202-
fBackgroundColor.dispose();
203-
fBackgroundColor = null;
204-
}
205-
206-
if (fSelectionForegroundColor != null) {
207-
fSelectionForegroundColor.dispose();
208-
fSelectionForegroundColor = null;
209-
}
210-
211-
if (fSelectionBackgroundColor != null) {
212-
fSelectionBackgroundColor.dispose();
213-
fSelectionBackgroundColor = null;
214-
}
215-
}
216179
}

0 commit comments

Comments
 (0)