@@ -605,7 +605,7 @@ def __init__(self, parent):
605605 self .topFrame .show ()
606606 else :
607607 self .newTabEditor (filename = None )
608-
608+
609609 ## Fixes #7653
610610 if sys .platform != 'darwin' :
611611 self .setDocumentMode (True )
@@ -732,7 +732,12 @@ def restoreTabs(self):
732732 tabName = pathFile .split ('/' )[- 1 ]
733733 self .newTabEditor (tabName , pathFile )
734734 else :
735- self .newTabEditor (filename = None )
735+ print '## Error: '
736+ s = 'Unable to restore the file: \n %s\n ' % pathFile
737+ sys .stderr .write (s )
738+ self .parent .updateTabListScript (pathFile )
739+ if self .count () < 1 :
740+ self .newTabEditor (filename = None )
736741 self .topFrame .close ()
737742 self .enableToolBarEditor (True )
738743
@@ -762,16 +767,18 @@ def listObject(self, tab):
762767 if tabWidget .path :
763768 pathFile , file = os .path .split (unicode (tabWidget .path ))
764769 module , ext = os .path .splitext (file )
770+ found = False
765771 if pathFile not in sys .path :
766772 sys .path .append (pathFile )
773+ found = True
767774 try :
768775 reload (pyclbr )
769776 dictObject = {}
770777 superClassName = []
771778 readModule = pyclbr .readmodule (module )
772779 readModuleFunction = pyclbr .readmodule_ex (module )
773780 for name , class_data in sorted (readModule .items (), key = lambda x :x [1 ].lineno ):
774- if class_data .file == tabWidget .path :
781+ if os . path . normpath ( str ( class_data .file )) == os . path . normpath ( str ( tabWidget .path )) :
775782 for superClass in class_data .super :
776783 if superClass == 'object' :
777784 continue
@@ -788,31 +795,39 @@ def listObject(self, tab):
788795 classItem .setText (0 , name )
789796 classItem .setToolTip (0 , name )
790797 classItem .setText (1 , str (class_data .lineno ))
791- classItem .setIcon (0 , QgsApplication .getThemeIcon ("console/iconClassTreeWidgetConsole.png" ))
798+ iconClass = QgsApplication .getThemeIcon ("console/iconClassTreeWidgetConsole.png" )
799+ classItem .setIcon (0 , iconClass )
792800 dictObject [name ] = class_data .lineno
793801 for meth , lineno in sorted (class_data .methods .items (), key = itemgetter (1 )):
794802 methodItem = QTreeWidgetItem ()
795803 methodItem .setText (0 , meth + ' ' )
796804 methodItem .setText (1 , str (lineno ))
797805 methodItem .setToolTip (0 , meth )
798- methodItem .setIcon (0 , QgsApplication .getThemeIcon ("console/iconMethodTreeWidgetConsole.png" ))
806+ iconMeth = QgsApplication .getThemeIcon ("console/iconMethodTreeWidgetConsole.png" )
807+ methodItem .setIcon (0 , iconMeth )
799808 classItem .addChild (methodItem )
800809 dictObject [meth ] = lineno
810+ # if found:
811+ # sys.path.remove(os.path.split(unicode(str(class_data.file)))[0])
801812 self .parent .listClassMethod .addTopLevelItem (classItem )
802813 for func_name , data in sorted (readModuleFunction .items (), key = lambda x :x [1 ].lineno ):
803- if isinstance (data , pyclbr .Function ) and data .file == tabWidget .path :
814+ if isinstance (data , pyclbr .Function ) and \
815+ os .path .normpath (str (data .file )) == os .path .normpath (str (tabWidget .path )):
804816 funcItem = QTreeWidgetItem ()
805817 funcItem .setText (0 , func_name + ' ' )
806818 funcItem .setText (1 , str (data .lineno ))
807819 funcItem .setToolTip (0 , func_name )
808- funcItem .setIcon (0 , QgsApplication .getThemeIcon ("console/iconFunctionTreeWidgetConsole.png" ))
820+ iconFunc = QgsApplication .getThemeIcon ("console/iconFunctionTreeWidgetConsole.png" )
821+ funcItem .setIcon (0 , iconFunc )
809822 dictObject [func_name ] = data .lineno
810823 self .parent .listClassMethod .addTopLevelItem (funcItem )
824+ if found :
825+ sys .path .remove (pathFile )
811826 except :
812827 s = traceback .format_exc ()
813828 print '## Error: '
814829 sys .stderr .write (s )
815-
830+
816831 def changeFont (self ):
817832 countTab = self .count ()
818833 for i in range (countTab ):
0 commit comments