<div dir="ltr"><div>Hello,<br><br>I've seen that two months ago (<a href="http://www.riverbankcomputing.com/pipermail/pyqt/2013-March/032458.html">http://www.riverbankcomputing.com/pipermail/pyqt/2013-March/032458.html</a>) a bug in PyQt caused QTextBlockUserData objects to be destroyed. This was announced to be fixed.<br>
<br>Yet I still experience the same behaviour. When using the following syntax highlighter:<br><br><blockquote>

</blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><p style="margin:0px;text-indent:0px">class DummyHighlighter(QSyntaxHighlighter):</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">    def __init__(self, parent):</p>
<p style="margin:0px;text-indent:0px">        QSyntaxHighlighter.__init__(self, parent)</p>
<p style="margin:0px;text-indent:0px"><br></p>
<style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style="margin:0px;text-indent:0px">    def highlightBlock(self, text):</p>
<p style="margin:0px;text-indent:0px">        data = self.currentBlockUserData()</p>
<p style="margin:0px;text-indent:0px">        if not data: data = DummyTextBlockUserData()</p>
<p style="margin:0px;text-indent:0px">        print(data.isValid())  # AttributeError here, see below</p>
<p style="margin:0px;text-indent:0px">        self.setCurrentBlockUserData(data)</p><p style="margin:0px;text-indent:0px"><br></p><p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">class DummyTextBlockUserData(QTextBlockUserData):</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">    def __init__(self):</p>
<p style="margin:0px;text-indent:0px">        QTextBlockUserData.__init__(self)</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">    def isValid(self):</p>
<p style="margin:0px;text-indent:0px">        return True</p></blockquote><style type="text/css">
p, li { white-space: pre-wrap; }
</style><br></div>I get the following error:<br><div><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
Traceback (most recent call last):<br>    File "highlighter.py", line 20, in highlightBlock<br>        print(data.isValid())<br>AttributeError: 'QTextBlockUserData' object has no attribute 'isValid'<br>
</blockquote><style type="text/css">
p, li { white-space: pre-wrap; }</style><div><div><br></div><div>This is using:<br></div><ul><li>PyQt 4.10.1</li><li>SIP 4.14.6</li><li>Python 2.7.4</li></ul><div>Is it still a bug?<br><br></div><div>Thanks for you help !<br>
<br clear="all"><div><div>Olivier Keshavjee<br>Ch. du Daillard 37<br>1070 Puidoux<br>+41 (0)76 345 47 49<br><a href="http://www.theologeek.ch" target="_blank">http://www.theologeek.ch</a><br></div></div>
</div></div></div></div>