crecord: restore SIGWINCH handler before return
authorJun Wu <quark@fb.com>
Wed, 24 Aug 2016 11:24:07 +0100
changeset 29835 bff109e6398a
parent 29834 1ea77b75d266
child 29836 18bac830eef3
crecord: restore SIGWINCH handler before return Previously, the SIGWINCH handler does not get cleared and if the commit message editor also needs SIGWINCH handling (like vim), the two SIGWINCH handlers (the editor's, ours) will have a race. And we may erase the editor's screen content. This patch restores SIGWINCH handler to address the above issue.
mercurial/crecord.py
--- a/mercurial/crecord.py	Sat Aug 20 23:06:01 2016 +0200
+++ b/mercurial/crecord.py	Wed Aug 24 11:24:07 2016 +0100
@@ -1263,7 +1263,6 @@
             self.statuswin.resize(self.numstatuslines, self.xscreensize)
             self.numpadlines = self.getnumlinesdisplayed(ignorefolding=True) + 1
             self.chunkpad = curses.newpad(self.numpadlines, self.xscreensize)
-            # todo: try to resize commit message window if possible
         except curses.error:
             pass
 
@@ -1589,7 +1588,8 @@
         method to be wrapped by curses.wrapper() for selecting chunks.
         """
 
-        signal.signal(signal.SIGWINCH, self.sigwinchhandler)
+        origsigwinchhandler = signal.signal(signal.SIGWINCH,
+                                            self.sigwinchhandler)
         self.stdscr = stdscr
         # error during initialization, cannot be printed in the curses
         # interface, it should be printed by the calling code
@@ -1640,3 +1640,4 @@
                 keypressed = "foobar"
             if self.handlekeypressed(keypressed):
                 break
+        signal.signal(signal.SIGWINCH, origsigwinchhandler)