From f45da78f5bd491dd9d0a78803898495ad27cf7d6 Mon Sep 17 00:00:00 2001 From: dmiller Date: Mon, 9 Apr 2018 16:17:09 +0000 Subject: [PATCH] Catch a file error when saving recent scans. Fixes #1177 --- zenmap/zenmapGUI/MainWindow.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/zenmap/zenmapGUI/MainWindow.py b/zenmap/zenmapGUI/MainWindow.py index 11188d577..d0d0de3b1 100644 --- a/zenmap/zenmapGUI/MainWindow.py +++ b/zenmap/zenmapGUI/MainWindow.py @@ -767,9 +767,18 @@ This scan has not been run yet. Start the scan with the "Scan" button first.')) scan_interface.saved_filename = directory # Saving recent scan information - for filename in filenames: - recent_scans.add_recent_scan(filename) - recent_scans.save() + try: + for filename in filenames: + recent_scans.add_recent_scan(filename) + recent_scans.save() + except (OSError, IOError), e: + alert = HIGAlertDialog( + message_format=_( + "Can't save recent scan information"), + secondary_text=_( + "Can't open file to write.\n%s") % str(e)) + alert.run() + alert.destroy() def _save(self, scan_interface, saved_filename, selected_index, format="xml"): @@ -794,8 +803,17 @@ This scan has not been run yet. Start the scan with the "Scan" button first.')) if format == "xml": # Saving recent scan information - recent_scans.add_recent_scan(saved_filename) - recent_scans.save() + try: + recent_scans.add_recent_scan(saved_filename) + recent_scans.save() + except (OSError, IOError), e: + alert = HIGAlertDialog( + message_format=_( + "Can't save recent scan information"), + secondary_text=_( + "Can't open file to write.\n%s") % str(e)) + alert.run() + alert.destroy() def get_empty_interface(self): """Return this window if it is empty, otherwise create and return a new