Fixing crashes when the sketch window is resized.

For the whole discussion see https://github.com/processing/processing/issues/1880