now checking if context is valid when dispatching RESIZE event (closes #528)