@@ -605,7 +605,7 @@ def __init__(self, parent):
605
605
self .topFrame .show ()
606
606
else :
607
607
self .newTabEditor (filename = None )
608
-
608
+
609
609
## Fixes #7653
610
610
if sys .platform != 'darwin' :
611
611
self .setDocumentMode (True )
@@ -732,7 +732,12 @@ def restoreTabs(self):
732
732
tabName = pathFile .split ('/' )[- 1 ]
733
733
self .newTabEditor (tabName , pathFile )
734
734
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 )
736
741
self .topFrame .close ()
737
742
self .enableToolBarEditor (True )
738
743
@@ -762,16 +767,18 @@ def listObject(self, tab):
762
767
if tabWidget .path :
763
768
pathFile , file = os .path .split (unicode (tabWidget .path ))
764
769
module , ext = os .path .splitext (file )
770
+ found = False
765
771
if pathFile not in sys .path :
766
772
sys .path .append (pathFile )
773
+ found = True
767
774
try :
768
775
reload (pyclbr )
769
776
dictObject = {}
770
777
superClassName = []
771
778
readModule = pyclbr .readmodule (module )
772
779
readModuleFunction = pyclbr .readmodule_ex (module )
773
780
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 )) :
775
782
for superClass in class_data .super :
776
783
if superClass == 'object' :
777
784
continue
@@ -788,31 +795,39 @@ def listObject(self, tab):
788
795
classItem .setText (0 , name )
789
796
classItem .setToolTip (0 , name )
790
797
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 )
792
800
dictObject [name ] = class_data .lineno
793
801
for meth , lineno in sorted (class_data .methods .items (), key = itemgetter (1 )):
794
802
methodItem = QTreeWidgetItem ()
795
803
methodItem .setText (0 , meth + ' ' )
796
804
methodItem .setText (1 , str (lineno ))
797
805
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 )
799
808
classItem .addChild (methodItem )
800
809
dictObject [meth ] = lineno
810
+ # if found:
811
+ # sys.path.remove(os.path.split(unicode(str(class_data.file)))[0])
801
812
self .parent .listClassMethod .addTopLevelItem (classItem )
802
813
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 )):
804
816
funcItem = QTreeWidgetItem ()
805
817
funcItem .setText (0 , func_name + ' ' )
806
818
funcItem .setText (1 , str (data .lineno ))
807
819
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 )
809
822
dictObject [func_name ] = data .lineno
810
823
self .parent .listClassMethod .addTopLevelItem (funcItem )
824
+ if found :
825
+ sys .path .remove (pathFile )
811
826
except :
812
827
s = traceback .format_exc ()
813
828
print '## Error: '
814
829
sys .stderr .write (s )
815
-
830
+
816
831
def changeFont (self ):
817
832
countTab = self .count ()
818
833
for i in range (countTab ):
0 commit comments