@@ -310,6 +310,7 @@ def __init__(self):
310310 GObject .Object .__init__ (self )
311311 self ._log = logging .getLogger (self .__class__ .__name__ )
312312 self ._log .setLevel (LOG_LEVEL )
313+ self ._is_loaded = False
313314 self ._ctags_version = None
314315
315316 filename = os .path .join (ICON_DIR , "source-code-browser.png" )
@@ -328,8 +329,10 @@ def do_activate(self):
328329 self ._sourcetree .show_line_numbers = self .show_line_numbers
329330 self ._sourcetree .expand_rows = self .expand_rows
330331 self ._sourcetree .sort_list = self .sort_list
332+
331333 panel = self .window .get_side_panel ()
332334 panel .add_item (self ._sourcetree , "SymbolBrowserPlugin" , "Source Code" , self .icon )
335+ self ._sourcetree .connect ("focus" , self .on_sourcetree_focus )
333336
334337 if self .ctags_version is not None :
335338 self ._sourcetree .connect ('tag-activated' , self .on_tag_activated )
@@ -379,8 +382,12 @@ def _init_settings(self):
379382 def _load_active_document_symbols (self ):
380383 """ Load the symbols for the given URI. """
381384 self ._sourcetree .clear ()
382- #while Gtk.events_pending(): # <-- segfault
383- #Gtk.main_iteration()
385+ self ._is_loaded = False
386+ # do not load if not the active tab in the panel
387+ panel = self .window .get_side_panel ()
388+ if not panel .item_is_active (self ._sourcetree ):
389+ return
390+
384391 document = self .window .get_active_document ()
385392 if document :
386393 location = document .get_location ()
@@ -405,7 +412,7 @@ def _load_active_document_symbols(self):
405412 self ._sourcetree .parse_file (filename , uri )
406413 os .unlink (filename )
407414 self ._loaded_document = document
408-
415+ self . _is_loaded = True
409416
410417 def on_active_tab_changed (self , window , tab , data = None ):
411418 self ._load_active_document_symbols ()
@@ -435,7 +442,12 @@ def on_setting_changed(self, settings, key, data=None):
435442 self ._sourcetree .sort_list = self .sort_list
436443 self ._sourcetree .expanded_rows = {}
437444 self ._load_active_document_symbols ()
438-
445+
446+ def on_sourcetree_focus (self , direction , data = None ):
447+ if not self ._is_loaded :
448+ self ._load_active_document_symbols ()
449+ return False
450+
439451 def on_tab_state_changed (self , window , data = None ):
440452 self ._load_active_document_symbols ()
441453
0 commit comments