1. TortoiseHg
  2. TortoiseHg
  3. thg


TK Soh  committed 3177845

hggtk/serve: fix random crashes caused by race condition in text update

...triggered by traceback in hgweb bwhen browsing server.

Error message captured:
process_request:..\\hg-tortoise-dev\\hggtk\\serve.py:252: GtkWarning:
gtk_text_layout_real_invalidate: assertion `layout->wrap_loop_count == 0' failed
self.textbuffer.insert(enditer, msg)
..\\hg-tortoise-dev\\hggtk\\serve.py:252: GtkWarning: Invalid text
buffer iterator: either the iterator is uninitialized, or the
characters/pixbufs/widgets in the buffer have been modified since the
iterator was created.
You must use marks, character numbers, or line numbers to preserve a
position across buffer modifications.
You can apply tags and insert marks without invalidating your iterators,
but any mutation that affects 'indexable' buffer contents (contents that
can be referred to by character offset) will invalidate all outstanding iterators
self.textbuffer.insert(enditer, msg)

  • Participants
  • Parent commits c45f40e
  • Branches default

Comments (0)

Files changed (1)

File hggtk/serve.py

View file
  • Ignore whitespace
         self.connect('delete-event', self._delete)
         # Pipe stderr, stdout to self.write
+        self._queue = Queue.Queue()
         sys.stdout = self
         sys.stderr = self
         global gservice
         gservice = None
-        q = Queue.Queue()
-        args = [self._root, q, 'serve', '--name', self.webname,
+        args = [self._root, self._queue, 'serve', '--name', self.webname,
                 '--port', str(port)]
         thread = threading.Thread(target=hglib.hgcmd_toq, args=args)
         while not gservice or not hasattr(gservice, 'httpd'):
         self._url = 'http://%s:%d/' % (gservice.httpd.fqaddr, port)
-        gobject.timeout_add(10, self.process_queue, q)
+        gobject.timeout_add(10, self.process_queue)
     def _stop_server(self):
         if gservice and not gservice.stopped:
     def flush(self, *args):
-    def write(self, msg, append=True):
+    def write(self, msg):
+        self._queue.put(msg)
+    def _write(self, msg, append=True):
         msg = unicode(msg, 'iso-8859-1')
         if append:
             enditer = self.textbuffer.get_end_iter()
-    def process_queue(self, q):
+    def process_queue(self):
         Handle all the messages currently in the queue (if any).
-        while q.qsize():
+        while self._queue.qsize():
-                msg = q.get(0)
-                self.write(msg)
+                msg = self._queue.get(0)
+                self._write(msg)
             except Queue.Empty: