Hi Detlev.
I've tracked down the problem in AssistantEric.
The following code appears in DbAPIsWorker.__storeApis:
lexer = QScintilla.Lexers.getLexer(language)
Apparently, the lexer object returned uses QFont somewhere, because when the
above code executes, I get the warning:
QFont: It is not safe to use text and fonts outside the GUI thread
when using a debug build of Qt 4.3.4.
The solution is simple, if a bit inelegant.
__storeApis only uses lexer to get its autoCompletionWordSeparators(), so we
just need to get these in the main GUI thread, instead of within the
DbAPIsWorker thread. The attached patch stores the ac word separators for
all supported languages in the constructor for DbAPIsWorker. __storeApis
then just looks up the word separators when needed.
A couple of lines down from the above line, there is the line:
lexer = self.__proxy.getLexer()
Which will have the same problem of accessing a GUI object outside the GUI
thread. It's never executed on my machine, so it's probably for some unusual
case (when __storeApis is called with language = None). I covered this case
by adding an autoCompletionWordSeparators() method to the DbAPIs class, which
as far as I can tell, is the only class ever used as __proxy. I haven't
tested this part of the patch, so if you know how to get that part of the
code to run, it should be tested.
This appears to have fixed the segfault problem I was having. At least, it
hasn't happened after a few hours of using Eric today.
-Dan
--- Plugin_Assistant_Eric-snapshot-20080726/AssistantEric/APIsManager.py 2008-07-20 04:00:19.000000000 -0500
+++ .eric4/eric4plugins/AssistantEric/APIsManager.py 2008-08-01 18:47:21.000000000 -0500
@@ -67,12 +67,22 @@
"""
QThread.__init__(self)
+ # Get the AC word separators for all of the languages that the editor supports.
+ # This has to be before we create a new thread, because access to GUI elements
+ # is not allowed from non-gui threads.
+ self.__wseps = {}
+ for language in QScintilla.Lexers.getSupportedLanguages().keys():
+ self.__wseps[language] = QScintilla.Lexers.getLexer(language).autoCompletionWordSeparators()
+
self.__proxy = proxy
self.__language = language
self.__apiFiles = apiFiles[:]
self.__aborted = False
self.__projectPath = projectPath
+ def __autoCompletionWordSeparators(self, language):
+ return self.__wseps.get(language, None)
+
def abort(self):
"""
Public method to ask the thread to stop.
@@ -149,12 +159,11 @@
@param language programming language of the file of the APIs (string)
"""
if language:
- lexer = QScintilla.Lexers.getLexer(language)
+ wseps = self.__autoCompletionWordSeparators(language)
else:
- lexer = self.__proxy.getLexer()
- if lexer is None:
+ wseps = self.__proxy.autoCompletionWordSeparators()
+ if wseps is None:
return
- wseps = lexer.autoCompletionWordSeparators()
db = QSqlDatabase.database(self.__language)
db.transaction()
@@ -375,6 +384,7 @@
else:
self.__initAsLanguage()
+
def __initAsProject(self):
"""
Private method to initialize as a project API object.
@@ -640,6 +650,12 @@
"""
return self.__lexer
+ def autoCompletionWordSeparators(self):
+ if self.__lexer:
+ return self.__lexer.autoCompletionWordSeparators()
+ return None
+
+
def event(self, evt):
"""
Protected method to handle events from the worker thread.
_______________________________________________
Eric mailing list
[email protected]
http://www.riverbankcomputing.com/mailman/listinfo/eric