Fixed crash in painter.