Commit 0586bd4a59ee2ce183db02c995ce60a3b57f1f3e

Authored by tfmoraes
1 parent b1aaf9c9

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 141 def SetDirectoryPath(self, path,recursive=True):
142 142 self.running = True
143 143 self.stoped = False
144   - thread.start_new_thread(self.GetDicomGroups,(path,recursive))
  144 + self.GetDicomGroups(path,recursive)
145 145  
146 146 def UpdateLoadFileProgress(self,cont_progress):
147 147 ps.Publisher().sendMessage("Update dicom load", cont_progress)
... ... @@ -155,17 +155,16 @@ class ProgressDicomReader:
155 155  
156 156 def GetDicomGroups(self, path, recursive):
157 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 160 if isinstance(value_progress, tuple):
161 161 self.UpdateLoadFileProgress(value_progress)
162 162 else:
163 163 self.EndLoadFile(value_progress)
164   - self.running = False
165 164  
166 165 #Is necessary in the case user cancel
167 166 #the load, ensure that dicomdialog is closed
168 167 if(self.stoped):
169 168 self.UpdateLoadFileProgress(None)
170 169 self.stoped = False
171   -
172 170 \ No newline at end of file
  171 +
... ...