[Qgis-developer] Plugin Memory Leak
Dario Magri
dario.magri at gmail.com
Tue Aug 3 05:23:20 EDT 2010
Hi,
I have a Qgis plugin C++. I have subclassing QgisVertexMarker because I wont
show on my application my custom icon.
This is my code:
/////////////////HEADER FILE
#ifndef HLVERTEXMARKER_H
#define HLVERTEXMARKER_H
#include <qgsvertexmarker.h>
class GUI_EXPORT hlVertexMarker : public QgsVertexMarker
{
public:
//! Icons
enum IconType
{
ICON_NONE,
ICON_CROSS,
ICON_X,
ICON_BOX,
ICON_CUSTOM
};
hlVertexMarker(QgsMapCanvas* mapCanvas);
void paint(QPainter* p);
void setIconFileName(QString xFileName);
QRectF boundingRect() const;
private:
QString m_xFileName;
};
#endif
//////////////////////////////////CPP File
#include <QPainter>
hlVertexMarker::hlVertexMarker(QgsMapCanvas *mapCanvas) :
QgsVertexMarker(mapCanvas)
{
}
void hlVertexMarker::setIconFileName(QString xFileName)
{
m_xFileName = xFileName;
}
void hlVertexMarker::paint(QPainter *p)
{
// setIconSize(48);
qreal s = ( mIconSize - 1 ) / 2;
QPen pen( mColor );
pen.setWidth( mPenWidth );
p->setPen( pen );
switch ( mIconType )
{
case ICON_NONE:
break;
case ICON_CROSS:
p->drawLine( QLineF( -s, 0, s, 0 ) );
p->drawLine( QLineF( 0, -s, 0, s ) );
break;
case ICON_X:
p->drawLine( QLineF( -s, -s, s, s ) );
p->drawLine( QLineF( -s, s, s, -s ) );
break;
case ICON_BOX:
p->drawLine( QLineF( -s, -s, s, -s ) );
p->drawLine( QLineF( s, -s, s, s ) );
p->drawLine( QLineF( s, s, -s, s ) );
p->drawLine( QLineF( -s, s, -s, -s ) );
break;
case ICON_CUSTOM:
QPixmap pixmap(QSize(48,48));
pixmap.load(m_xFileName);
p->drawPixmap(0, 0,pixmap);
break;
}
}
QRectF hlVertexMarker::boundingRect() const
{
//Bounding Box
qreal s = qreal(mIconSize) / 2.0;
return QRectF( -2.0*s, -2.0*s, 2.0*s, 2.0*s );
}
Whe on my plugin I use my custom VertexMarke Qgis after few second crash. If
I use standard QgisVertexMarker the program work correctly.
Can anyone help me please??
bye
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20100803/f885843e/attachment.html
More information about the Qgis-developer
mailing list