Commits

Yuya Nishihara committed 82e13d2

filedialogs: make sure to sync page step of diffblock after actually changed

pageStep is updated by Scintilla.resizeEvent. Because each widget receives
the event in arbitrary order, BlockMatch.resizeEvent may be invoked before
Scintilla.resizeEvent. As a result, diffblock is rendered wrongly until
next resize event.

Comments (0)

Files changed (2)

tortoisehg/hgqt/blockmatcher.py

             self.update()
             self.pageStepChanged.emit(pagestep, side)
 
+    @pyqtSlot()
     def syncPageStep(self):
         for side in ['left', 'right']:
             self.setPageStep(self._sbar[side].pageStep(), side)
 
-    def resizeEvent(self, event):
-        self.syncPageStep()
-
     def linkScrollBar(self, sb, side):
         """
         Make the block list displayer be linked to the scrollbar

tortoisehg/hgqt/filedialogs.py

 
         for side, idx  in (('left', 0), ('right', 3)):
             sci = Scintilla(self.frame)
+            sci.installEventFilter(self)
             sci.verticalScrollBar().setFocusPolicy(Qt.StrongFocus)
             sci.setFocusProxy(sci.verticalScrollBar())
             sci.verticalScrollBar().installEventFilter(self)
         self.setTabOrder(table, self.viewers['left'])
         self.setTabOrder(self.viewers['left'], self.viewers['right'])
 
+        # timer used to merge requests of syncPageStep on ResizeEvent
+        self._delayedSyncPageStep = QTimer(self, interval=0, singleShot=True)
+        self._delayedSyncPageStep.timeout.connect(self.diffblock.syncPageStep)
+
         # timer used to fill viewers with diff block markers during GUI idle time
         self.timer = QTimer()
         self.timer.setSingleShot(False)
         elif len(self.filerevmodel.graph):
             self.goto(self.filerevmodel.graph[0].rev)
 
+    def eventFilter(self, watched, event):
+        if watched in self.viewers.values():
+            # copy page steps to diffblock _after_ viewers are resized; resize
+            # events will be posted in arbitrary order.
+            if event.type() == QEvent.Resize:
+                self._delayedSyncPageStep.start()
+            return False
+        else:
+            return super(FileDiffDialog, self).eventFilter(watched, event)
+
     def onRevisionSelected(self, rev):
         if rev is None or rev not in self.filerevmodel.graph.nodesdict:
             return