Anonymous avatar Anonymous committed 7389cfe

datamine: stop all search threads when quitting

else the python process won't quit until all searches are done,
even though the datamine window has been dismissed.

Comments (0)

Files changed (1)

hggtk/datamine.py

 
     def get_tbbuttons(self):
         self.stop_button = self.make_toolbutton(gtk.STOCK_STOP, 'Stop', 
-                self._stop_search, tip='Stop operation on current tab')
+                self._stop_current_search, tip='Stop operation on current tab')
         return [
             self.make_toolbutton(gtk.STOCK_FIND, 'New Search', 
                 self._search_clicked, tip='Open new search tab'),
         self.stop_button.set_sensitive(False)
         return vbox
 
+    def _destroying(self, gtkobj):
+        self._stop_all_searches()
+        GDialog._destroying(self, gtkobj)
+
     def ann_header_context_menu(self, treeview):
         _menu = gtk.Menu()
         _button = gtk.CheckMenuItem("Filename")
             self.curpath = fromutf(model[iter][self.COL_PATH])
             self.stbar.set_status_text(toutf(model[iter][self.COL_TOOLTIP]))
 
-    def _stop_search(self, button, widget):
+    def _stop_current_search(self, button, widget):
         num = self.notebook.get_current_page()
         frame = self.notebook.get_nth_page(num)
+        self._stop_search(frame)
+
+    def _stop_all_searches(self):
+        for num in xrange(self.notebook.get_n_pages()):
+            frame = self.notebook.get_nth_page(num)
+            self._stop_search(frame)
+
+    def _stop_search(self, frame):
         if hasattr(frame, '_mythread') and frame._mythread:
             frame._mythread.terminate()
             frame._mythread.join()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.