Commit 0586bd4a59ee2ce183db02c995ce60a3b57f1f3e
1 parent
b1aaf9c9
Exists in
master
and in
6 other branches
ENH: Using generator instead of thread to update the progressdialog
Showing
1 changed file
with
4 additions
and
5 deletions
Show diff stats
invesalius/reader/dicom_reader.py
@@ -141,7 +141,7 @@ class ProgressDicomReader: | @@ -141,7 +141,7 @@ class ProgressDicomReader: | ||
141 | def SetDirectoryPath(self, path,recursive=True): | 141 | def SetDirectoryPath(self, path,recursive=True): |
142 | self.running = True | 142 | self.running = True |
143 | self.stoped = False | 143 | self.stoped = False |
144 | - thread.start_new_thread(self.GetDicomGroups,(path,recursive)) | 144 | + self.GetDicomGroups(path,recursive) |
145 | 145 | ||
146 | def UpdateLoadFileProgress(self,cont_progress): | 146 | def UpdateLoadFileProgress(self,cont_progress): |
147 | ps.Publisher().sendMessage("Update dicom load", cont_progress) | 147 | ps.Publisher().sendMessage("Update dicom load", cont_progress) |
@@ -155,17 +155,16 @@ class ProgressDicomReader: | @@ -155,17 +155,16 @@ class ProgressDicomReader: | ||
155 | 155 | ||
156 | def GetDicomGroups(self, path, recursive): | 156 | def GetDicomGroups(self, path, recursive): |
157 | y = yGetDicomGroups(path, recursive) | 157 | y = yGetDicomGroups(path, recursive) |
158 | - while self.running: | ||
159 | - value_progress = y.next() | 158 | + #while self.running: |
159 | + for value_progress in y: | ||
160 | if isinstance(value_progress, tuple): | 160 | if isinstance(value_progress, tuple): |
161 | self.UpdateLoadFileProgress(value_progress) | 161 | self.UpdateLoadFileProgress(value_progress) |
162 | else: | 162 | else: |
163 | self.EndLoadFile(value_progress) | 163 | self.EndLoadFile(value_progress) |
164 | - self.running = False | ||
165 | 164 | ||
166 | #Is necessary in the case user cancel | 165 | #Is necessary in the case user cancel |
167 | #the load, ensure that dicomdialog is closed | 166 | #the load, ensure that dicomdialog is closed |
168 | if(self.stoped): | 167 | if(self.stoped): |
169 | self.UpdateLoadFileProgress(None) | 168 | self.UpdateLoadFileProgress(None) |
170 | self.stoped = False | 169 | self.stoped = False |
171 | - | ||
172 | \ No newline at end of file | 170 | \ No newline at end of file |
171 | + |