Fix a few issues with undo and modified state of views

Based on TortoiseSVN revision 24214

Signed-off-by: Sup Yut Sum <ch3cooli@gmail.com>