Ensure the staging_cairo_surface is destroyed before re-assigning it
Without doing so, memory regions allocated may not be freed in some cases.
Closes #6675.
I'm not sure if the change is reasonable; please have someone review it.
Edited by yingchao yang