[Qgis-developer] Problems with QgsPluginLayerRegistry

Sören Gebbert soerengebbert at googlemail.com
Wed Sep 2 15:04:04 PDT 2015


Dear all,
it seems to me that the QgsPluginLayerRegistry does not upcast the
object types correctly when createLayer() is called.

I have written a Python test that shows this problem.
Code and output of my test is located at pastebin.com:

http://pastebin.com/x68ft55D

In the example code i created a TestLayer class derived from QgsPluginLayer.
I created the according TestLayerType and registered them in the
QgsPluginLayerRegistry.

When calling createLayer() of the registry the registered TestLayerType object
seems to create the correct object. however, the TestLayer object is
casted to QgsPluginLayer
by the registry and the wrong functions are called (draw() and
noise()) from the base class.

I have no idea if this is a compiler problem, but i am not able to use
the QgsPluginLayer concept
in my QGIS plugin.

The problem appeared on Ubuntu 14.04 64Bit on AMD and Intel CPU.
C++ version is (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4.
I have tested the script with qgis-2.8.1 and 2.11 r7934a92. It fails
in booth cases.

The watermark plugin seems to be affected as well.

Any idea howto fix this?

Best regards
Soeren


More information about the Qgis-developer mailing list