Some undo issue preventions for clearImage & deleteSelection

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