Skip to content

Commit

Permalink
fixed race condition #9
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Nyre221 authored Sep 21, 2023
1 parent 9382efb commit 2c47b0f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions container_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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():
Expand All @@ -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():
Expand All @@ -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():
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2c47b0f

Please sign in to comment.