Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.1, 2.1.1, and 2.1.2

workbench: do not crash when trying to close invalid tab widget

This patch also removes some trailing white spaces.

Changeset 05c5894c290f

Parent 2247c0b95777

by Angel Ezquerra

Changes to one file · Browse files at 05c5894c290f Showing diff from parent 2247c0b95777 Diff from another changeset...

 
74
75
76
77
 
78
79
80
 
366
367
368
369
 
370
371
372
 
379
380
381
382
 
383
384
385
386
 
387
388
389
390
391
 
392
393
394
395
396
 
397
398
399
 
405
406
407
408
409
 
 
 
410
411
412
 
418
419
420
421
422
 
 
423
424
425
 
426
427
428
 
552
553
554
555
 
 
 
 
556
557
558
 
560
561
562
563
564
565
566
567
568
569
570
 
 
 
 
 
 
 
 
 
 
 
 
571
572
573
 
74
75
76
 
77
78
79
80
 
366
367
368
 
369
370
371
372
 
379
380
381
 
382
383
384
385
 
386
387
388
389
390
 
391
392
393
394
395
 
396
397
398
399
 
405
406
407
 
 
408
409
410
411
412
413
 
419
420
421
 
 
422
423
424
425
 
426
427
428
429
 
553
554
555
 
556
557
558
559
560
561
562
 
564
565
566
 
 
 
 
 
 
 
 
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
@@ -74,7 +74,7 @@
  self.dockMenu.addAction(_('Open Repository...'),   self.openRepository)   qt_mac_set_dock_menu(self.dockMenu) - +   # Create the actions that will be displayed on the context menu   self.createActions()   self.lastClosedRepoRootList = [] @@ -366,7 +366,7 @@
  if cb:   act.triggered.connect(cb)   self.addAction(act) - +   @pyqtSlot(QPoint)   def tabBarContextMenuRequest(self, point):   # Activate the clicked tab @@ -379,21 +379,21 @@
  clickedtabindex = clickedwidget.tabAt(point)   if clickedtabindex > -1:   self.repoTabsWidget.lastClickedTab = clickedtabindex - +   actionlist = ['closetab', 'closeothertabs']     existingClosedRepoList = [] - +   for reporoot in self.lastClosedRepoRootList:   if os.path.isdir(reporoot):   existingClosedRepoList.append(reporoot)   self.lastClosedRepoRootList = existingClosedRepoList - +   if len(self.lastClosedRepoRootList) > 1:   actionlist += ['', 'reopenlastclosedgroup']   elif len(self.lastClosedRepoRootList) > 0:   actionlist += ['', 'reopenlastclosed'] - +   contextmenu = QMenu(self)   for act in actionlist:   if act: @@ -405,8 +405,9 @@
  contextmenu.exec_(self.repoTabsWidget.mapToGlobal(point))     def closeLastClickedTab(self): - self.repoTabCloseRequested(self.repoTabsWidget.lastClickedTab) - + if self.repoTabsWidget.lastClickedTab > -1: + self.repoTabCloseRequested(self.repoTabsWidget.lastClickedTab) +   def _closeOtherTabs(self, tabIndex):   if tabIndex > -1:   tb = self.repoTabsWidget.tabBar() @@ -418,11 +419,11 @@
  # repoTabCloseRequested updates self.lastClosedRepoRootList   closedRepoRootList += self.lastClosedRepoRootList   self.lastClosedRepoRootList = closedRepoRootList - - + +   def closeNotLastClickedTabs(self):   self._closeOtherTabs(self.repoTabsWidget.lastClickedTab) - +   def onSwitchRepoTaskTab(self, action):   rw = self.repoTabsWidget.currentWidget()   if rw: @@ -552,7 +553,10 @@
  index = self.repoTabsWidget.currentIndex()   if widget.closeRepoWidget():   w = self.repoTabsWidget.widget(index) - reporoot = w.repo.root + try: + reporoot = w.repo.root + except: + reporoot = ''   self.repoTabsWidget.removeTab(index)   widget.deleteLater()   self.updateMenu() @@ -560,14 +564,18 @@
    def repoTabCloseRequested(self, index):   tw = self.repoTabsWidget - w = tw.widget(index) - reporoot = w.repo.root - if w and w.closeRepoWidget(): - tw.removeTab(index) - w.deleteLater() - self.updateMenu() - self.lastClosedRepoRootList = [reporoot] - + if 0 <= index < tw.count(): + w = tw.widget(index) + try: + reporoot = w.repo.root + except: + reporoot = '' + if w and w.closeRepoWidget(): + tw.removeTab(index) + w.deleteLater() + self.updateMenu() + self.lastClosedRepoRootList = [reporoot] +   def reopenLastClosedTabs(self):   for reporoot in self.lastClosedRepoRootList:   if os.path.isdir(reporoot):