From 1e57054bd2b2bff498cc1921fa892682ac121724 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 6 Apr 2019 01:38:19 +0300 Subject: [PATCH] - fixed issue with not possible to close the app after a project save (for real this time) --- FlatCAMApp.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 1c170cec..1e229712 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -7896,6 +7896,7 @@ The normal flow when working in FlatCAM is the following:

:return: None """ self.log.debug("save_project()") + self.save_in_progress = True with self.proc_container.new(_("Saving FlatCAM Project")) as proc: ## Capture the latest changes @@ -7953,26 +7954,25 @@ The normal flow when working in FlatCAM is the following:

else: self.inform.emit(_("[ERROR_NOTCL] Failed to save project file: %s. Retry to save it.") % filename) - if quit: + # if quit: # t = threading.Thread(target=lambda: self.check_project_file_size(1, filename=filename)) # t.start() - self.save_in_progress = True - self.start_delayed_quit(delay=500, filename=filename) + self.start_delayed_quit(delay=500, filename=filename, quit=quit) - def start_delayed_quit(self, delay, filename): + def start_delayed_quit(self, delay, filename, quit=None): """ :param delay: period of checking if project file size is more than zero; in seconds :param filename: the name of the project file to be checked periodically for size more than zero :return: """ + to_quit = quit + self.save_timer = QtCore.QTimer() + self.save_timer.setInterval(delay) + self.save_timer.timeout.connect(lambda : self.check_project_file_size(filename=filename, quit=to_quit)) + self.save_timer.start() - self.quit_timer = QtCore.QTimer() - self.quit_timer.setInterval(delay) - self.quit_timer.timeout.connect(lambda : self.check_project_file_size(filename=filename)) - self.quit_timer.start() - - def check_project_file_size(self, filename): + def check_project_file_size(self, filename, quit=None): """ :param filename: the name of the project file to be checked periodically for size more than zero @@ -7981,8 +7981,10 @@ The normal flow when working in FlatCAM is the following:

try: if os.stat(filename).st_size > 0: - self.quit_timer.stop() - self.app_quit.emit() + self.save_in_progress = False + self.save_timer.stop() + if quit: + self.app_quit.emit() except Exception: traceback.print_exc()