Process all pending GUI events before loading Mantid

Refs #10798
Merge branch 'bugfix/10798_setup_pv_z_order' into develop