some undo issue preventions (clearImage & deleteSelection)

1. Prevent from unnecessary updates
2. Prevent from extra undo backups
3. Optimised if-else