diff --git a/src/gajim.py b/src/gajim.py
index 49ba4122ff9220a7c784ec8144d5460277e3a1be..80d21953a4c0436ed78a3f8124f3e0e83051f780 100644
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -454,6 +454,9 @@ if __name__ == '__main__':
             # This makes Gajim unusable under windows, and threads are used only
             # for GPG, so not under windows
             gtk.gdk.threads_init()
+            gtk.gdk.threads_enter()
         gtk.main()
+        if os.name != 'nt':
+            gtk.gdk.threads_leave()
     except KeyboardInterrupt:
         print >> sys.stderr, 'KeyboardInterrupt'