Fix a segmentation fault

Fix the segmentation fault caused by clicking on the "Cancel" button of the export dialog, as in issue #249.
Merge pull request #278 from M374LX/stable-0.4

Fix a segmentation fault