Avoid crash when dialog dismissed via back button.

A user usually presses the back button only
when he/she does not want the changes to be saved.
Hence we need to revert the changes that took place
when the dialog is dismissed with back button.

Change-Id: Ia4a65e93487fedb51d284e6d08b4364e570f4887