[PyQt] QScintilla code-completion bizarre behavior

Brian Kelley kelley at eyesopen.com
Tue Sep 23 14:16:52 BST 2008


On Sep 22, 2008, at 8:25 PM, Baz Walter wrote:

> Brian Kelley wrote:
> [snip]
>>    def start(self):
>>        lexer =  self.lexer = QsciLexerPython()
>>        api = QsciAPIs(lexer)
>>        # write the API to a file
>>        self.api = api
>
> you save references to your lexer and api here
>
> then (bizarrely) create a new lexer and api here

This is not as bizarre as you might think.  It can take minutes to  
prepare an api which is why the editor uses a different  
instantiation.  The reason it looks odd in this case is because it is  
an example after all.

You did point me in the right direction, it looks like the lexer and  
api are not reference counted when given to Scintilla, apparently  
raising an exception interferes with this mechanism so they aren't  
garbage collected which causes the correct behavior.

Brian Kelley


>
>
> [snip]
>>        # uncommenting this exception causes code-completion not to  
>> work.
>>        raise Exception("Why does this exception make code- 
>> completion work?")
>
> my guess is that if you hook self.editor up to self.lexer and  
> self.api it will all work fine
>
> -
> Regards
> Baz Walter



More information about the PyQt mailing list