On Sat, 14 Jan 2017 at 23:24:25 +0000, James Clarke wrote:
> I'm not sure why it's working for me and not you.
Ah, that would be because I have reportbug configured to use mutt to write
the actual bug report, and that disables the Gtk editor.
Your change looks fine. I also needed to use the attached.
S
>From dd64cbfb2d8f8b4c816cffdd43d9be41c1aedfa3 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Sat, 14 Jan 2017 23:48:12 +0000
Subject: [PATCH 7/8] gtk2_ui: lazily import gtkspellcheck from the UI thread
If we import it globally (in the reportbug thread), we get:
sqlite3.ProgrammingError: SQLite objects created in a thread can only be
used in that same thread. The object was created in thread id
<some large number> and this is thread id <some other large number>
---
reportbug/ui/gtk2_ui.py | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/reportbug/ui/gtk2_ui.py b/reportbug/ui/gtk2_ui.py
index 5a5e92c..ca89eaf 100644
--- a/reportbug/ui/gtk2_ui.py
+++ b/reportbug/ui/gtk2_ui.py
@@ -47,11 +47,7 @@ except ImportError:
global Vte
-try:
- import gtkspellcheck
- has_spell = True
-except:
- has_spell = False
+gtkspellcheck = None
#gtk.set_interactive(0)
Gdk.threads_init()
@@ -1309,7 +1305,18 @@ class EditorPage(Page):
self.view = Gtk.TextView()
self.view.modify_font(Pango.FontDescription("Monospace"))
self.view.set_wrap_mode(Gtk.WrapMode.WORD)
- if has_spell:
+
+ # We have to do the import in the UI thread, because it loads a
+ # SQLite database at import time, and the Python SQLite bindings
+ # don't allow transferring a SQLite handle between threads.
+ global gtkspellcheck
+ if gtkspellcheck is None:
+ try:
+ import gtkspellcheck
+ except:
+ gtkspellcheck = NotImplemented
+
+ if gtkspellcheck is not NotImplemented:
gtkspellcheck.SpellChecker(self.view)
self.info_buffer = self.view.get_buffer()
scrolled = create_scrollable(self.view)
@@ -1323,7 +1330,7 @@ class EditorPage(Page):
expander.add(scrolled)
vbox.pack_start(expander, False, True, 0)
- if not has_spell:
+ if gtkspellcheck is NotImplemented:
box = Gtk.EventBox()
label = Gtk.Label("Please install <b>python-gtkspellcheck</b> to enable spell checking")
label.set_use_markup(True)
--
2.11.0
_______________________________________________
Reportbug-maint mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reportbug-maint