From 2c47b0f918cd8c0142f503e44eaa1f35cdf21a11 Mon Sep 17 00:00:00 2001 From: Nyre221 <104171042+Nyre221@users.noreply.github.com> Date: Fri, 22 Sep 2023 00:34:58 +0200 Subject: [PATCH] fixed race condition #9 some times the contents of folders would not load. a better way to terminate a thread when content viewer is hidden needs to be implemented. --- container_viewer.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/container_viewer.py b/container_viewer.py index b93a0af..b8bad7f 100644 --- a/container_viewer.py +++ b/container_viewer.py @@ -198,7 +198,7 @@ def __load_folder__(self, path): # create the object for qlistwidget. for file in ordered_files: - if thread_id is not self.current_thread_id or self.isHidden(): + if thread_id is not self.current_thread_id: # exits if the id has changed (this happens when the user changes files). exit() # gets the icon appropriate for the file type. @@ -220,7 +220,7 @@ def __load_zip__(self, path): zip_infolist = zip_ref.infolist() # gets a list of the files and create the object for qlistwidget. for file in zip_infolist: - if thread_id is not self.current_thread_id or self.isHidden(): + if thread_id is not self.current_thread_id: # exits if the id has changed (this happens when the user changes files). exit() if not file.is_dir(): @@ -244,7 +244,7 @@ def __load_rar__(self, path): rar_infolist = rar_ref.infolist() # gets a list of the files and create the object for qlistwidget. for file in rar_infolist: - if thread_id is not self.current_thread_id or self.isHidden(): + if thread_id is not self.current_thread_id: # exits if the id has changed (this happens when the user changes files). exit() if not file.is_dir(): @@ -268,7 +268,7 @@ def __load_tar__(self, path): tar_infolist = tar_ref.getmembers() # gets a list of the files and create the object for qlistwidget. for file in tar_infolist: - if thread_id is not self.current_thread_id or self.isHidden(): + if thread_id is not self.current_thread_id: # exits if the id has changed (this happens when the user changes files). exit() if not file.isdir(): @@ -394,7 +394,7 @@ def get_size(self, path): # adds the size of each file to the size variable for subfolder_path, dirs, files in os.walk(path): for f in files: - if thread_id is not self.current_thread_id or self.isHidden(): + if thread_id is not self.current_thread_id: # exits if the id has changed (this happens when the user changes files). exit() subfile_path = os.path.join(subfolder_path, f)