Fix another crash due to a null cursor.
Interesting that hasSelection() can be true even if the cursor now points to a null document (deleted meanwhile, likely)