From d78b4c9c2724aff6320d20f83abd37750d31a7c9 Mon Sep 17 00:00:00 2001
From: Luke Macken <lmacken@redhat.com>
Date: Thu, 17 Jun 2010 10:28:48 -0400
Subject: [PATCH] Call gtk.threads_{enter,leave} before & after taking the screenshot.

This fixes ticket #1904, which seems to be a race-condition that I am
able to reliably reproduce on the XO-1.5 but not on the 1.0.

http://bugs.sugarlabs.org/ticket/1904

diff --git a/journal.py b/journal.py
index 7ef47f2..3668aaa 100644
--- a/journal.py
+++ b/journal.py
@@ -328,6 +328,7 @@ class JournalInteraction():
 
     def take_screenshot(self, waveform_id = 1):
         #file_path = os.path.join(tempfile.gettempdir(), '%i' % time.time())
+        gtk.threads_enter()
         act_root = environ['SUGAR_ACTIVITY_ROOT'] 
         tmp_dir = join(act_root, 'data')
         tmp_fd, file_path = tempfile.mkstemp(dir=tmp_dir)
@@ -367,6 +368,7 @@ class JournalInteraction():
         finally:
             os.close(tmp_fd)
             os.remove(file_path)
+            gtk.threads_leave()
 
 """
 #FOR TESTING JOURNALINTERACTION CLASS
-- 
1.7.1

