Bug 276202 [Forms] NPE if dispose() called on FormToolkit more than once
Build id: I20090512-2000 java.lang.NullPointerException at org.eclipse.ui.forms.widgets.FormToolkit.dispose(FormToolkit.java:711) At the moment, if you invoke dispose() twice on a FormToolkit instance, an NPE will be thrown. public void dispose() { if (colors.isShared() == false) { colors.dispose(); colors = null; } boldFontHolder.dispose(); } As can be seen, the 'colors' field is set to 'null' which is the cause of the NPE. It's okay to repeatedly invoke dispose() on an SWT widget so I feel this pattern should be extended for a FormToolkit also.
bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/FormToolkit.java
Section section = new Section(parent, orientation, sectionStyle);
		section.setMenu(parent.getMenu());
		adapt(section, true, true);
		if (section.toggle != null) {
			section.toggle.setHoverDecorationColor(colors
					.getColor(IFormColors.TB_TOGGLE_HOVER));
			section.toggle.setDecorationColor(colors
					.getColor(IFormColors.TB_TOGGLE));
		}
		section.setFont(boldFontHolder.getBoldFont(parent.getFont()));
		if ((sectionStyle & Section.TITLE_BAR) != 0
				|| (sectionStyle & Section.SHORT_TITLE_BAR) != 0) {
			colors.initializeSectionToolBarColors();
			section.setTitleBarBackground(colors.getColor(IFormColors.TB_BG));
			section.setTitleBarBorderColor(colors
					.getColor(IFormColors.TB_BORDER));
		}
		
		section.setTitleBarForeground(colors
				.getColor(IFormColors.TB_TOGGLE));
		return section;
	}
	/**
	 * Creates an expandable composite as a part of the form.
	 * 
	 * @param parent
	 *            the expandable composite parent
	 * @param expansionStyle
	 *            the expandable composite style
	 * @return the expandable composite widget