Recover Context after redraw Calling context.area.ui_type = 'IMAGE_EDITOR' succeeds before redraw.
After redrawing using bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) it fails, with the error:
AttributeError: 'NoneType' object has no attribute 'ui_type'
How can I restore the context so that area is not NoneType ?
The solution was to Override the Context
Before calling redraw, create the override
override = context.copy()
After redraw, set the area on the override instead of the context object
override['area'].ui_type = 'IMAGE_EDITOR'
Any bpy.ops.* calls must pass the override as the 1st argument eg:
bpy.ops.image.save_as(override, filepath = fileName)