[PyQt] [BUG] Return value of overriden QSGMaterial::createShader() impropely destroyed before use
Vladimir Rutsky
rutsky.vladimir at gmail.com
Tue Jun 2 13:07:41 BST 2015
Hello,
QSGMaterial::createShader() documentation says:
> This function returns a new instance of a the QSGMaterialShader implementatation used to render geometry for a specific implementation of QSGMaterial.
> The function will be called only once for each material type that exists in the scene graph and will be cached internally.
So it seems to be valid to do in Python:
class MyMaterial(QSGMaterial):
...
def createShader(self):
return MyMaterialShader()
But this code leads to segfault in Qt C++ code while rendering ---
looks like ownership of created MyMaterialShader() is not being
transferred to C++ code (not sure how this properly should be done),
and MyMaterialShader() is being detroyed before use.
As workaround I can store created shader, this code works:
class MyMaterial(QSGMaterial):
...
def createShader(self):
self._shader = MyMaterialShader()
return self._shader
Regards,
Vladimir Rutsky
More information about the PyQt
mailing list