Skip to content

Commit e15424a

Browse files
author
wonder
committedNov 14, 2008
PyQGIS fix: QgsMapLayer has QObject as subclass
(it wasn't possible to connect to its signals) git-svn-id: http://svn.osgeo.org/qgis/trunk@9637 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 19bc6b9 commit e15424a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed
 

‎python/core/qgsmaplayer.sip

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@
33
* \brief Base class for all map layer types.
44
* This class is the base class for all map layer types (vector, raster).
55
*/
6-
class QgsMapLayer // TODO: problem when derived from QObject
6+
class QgsMapLayer : QObject
77
{
88
%TypeHeaderCode
99
#include <qgsmaplayer.h>
1010
%End
1111

1212
%ConvertToSubClassCode
13-
14-
if (sipCpp->type() == QgsMapLayer::VectorLayer)
15-
{
16-
sipClass = sipClass_QgsVectorLayer;
17-
}
18-
else if (sipCpp->type() == QgsMapLayer::RasterLayer)
13+
if (sipCpp->inherits("QgsMapLayer"))
1914
{
20-
sipClass = sipClass_QgsRasterLayer;
15+
sipClass = sipClass_QgsMapLayer;
16+
QgsMapLayer* layer = qobject_cast<QgsMapLayer*>(sipCpp);
17+
if (layer->type() == QgsMapLayer::VectorLayer)
18+
{
19+
sipClass = sipClass_QgsVectorLayer;
20+
}
21+
else if (layer->type() == QgsMapLayer::RasterLayer)
22+
{
23+
sipClass = sipClass_QgsRasterLayer;
24+
}
2125
}
2226
else
2327
{

0 commit comments

Comments
 (0)
Please sign in to comment.