[PyQt] QTextLayout.createLine crashes

Phil Thompson phil at riverbankcomputing.com
Mon Mar 27 13:28:40 BST 2017


On 27 Mar 2017, at 10:11 am, Jérôme Laheurte <jerome at jeromelaheurte.net> wrote:
> 
> Hello. This smells like a bug; I was « porting » the ElidedLabel sample when I stumbled upon it. The following code crashes with a SIGSEGV in createLine() (Qt/PyQt 5.8.1, mac OS 10.11.6):
> 
> 
> from PyQt5 import QtWidgets, QtGui
> 
> 
> class TestWidget(QtWidgets.QWidget):
>    def paintEvent(self, event):
>        painter = QtGui.QPainter(self)
>        layout = QtGui.QTextLayout('spam', painter.font())
>        line = layout.createLine()
> 
> 
> app = QtWidgets.QApplication([])
> win = TestWidget()
> win.show()
> win.raise_()
> app.exec_()
> 
> I tried keeping a reference on the string and the font (and creating my own font), same result every time. Any idea ?

A C++ version seems to behave in the same way.

Phil


More information about the PyQt mailing list