Hi,
I have a Qgis C++ plugin that adds a tool, I build my plugin using the
libraries of Qgis built from sources
<https://github.com/qgis/QGIS/tree/release-2_4> with Microsoft Visual
Studio as described here
<http://htmlpreview.github.io/?https://raw.github.com/qgis/QGIS/master/doc/I
NSTALL.html#toc14> .
My tool works fine with built Qgis but not with the installed Qgis 2.4.
When I activate my tool and then turn to another tool Qgis crash and write a
minimum dump file:
Dump File: qgis-20140915-111427-2760-1564-8fdd08a.dmp :
C:\Users\Admin\AppData\Local\Temp\qgis-20140915-111427-2760-1564-8fdd08a.dmp
Last Write Time: 15/09/2014 11:14:28 Process Name: qgis-bin.exe : C:\Program
Files (x86)\QGIS Chugiak\bin\qgis-bin.exe Process Architecture: x86
Exception Code: 0xC0000005 Exception Information: The thread tried to read
from or write to a virtual address for which it does not have the
appropriate access. Heap Information: Not Present
For more details see the attached files
Best regards
Nejia
class GeoAdvancedEditTool: public QObject, public QgisPlugin
{
Q_OBJECT
public:
GeoAdvancedEditTool::GeoAdvancedEditTool( QgisInterface * tInterface ):
QgisPlugin ( sName, sDescription, sCategory, sPluginVersion,
sPluginType ),
m_ptInterface ( tInterface )
{
}
GeoAdvancedEditTool::~GeoAdvancedEditTool ()
{
}
void GeoAdvancedEditTool::run ()
{
}
void GeoAdvancedEditTool::initGui ()
{
m_ptMapToolAdvancedEditPolygons = new
MapToolAdvancedEditPolygons( m_ptInterface );
}
void GeoAdvancedEditTool::unload ()
{
if ( m_ptMapToolAdvancedEditPolygons )
{
delete m_ptMapToolAdvancedEditPolygons;
}
}
private:
QgisInterface *m_ptInterface;
MapToolAdvancedEditPolygons *m_ptMapToolAdvancedEditPolygons;
};
class MapToolAdvancedEditPolygons: public QgsMapToolVertexEdit
{
Q_OBJECT
public:
MapToolAdvancedEditPolygons::MapToolAdvancedEditPolygons( QgisInterface
*ptInterface )
: QgsMapToolVertexEdit( ptInterface->mapCanvas () )
, m_ptInterface ( ptInterface )
{
m_ptAdvancedEditAction = new QAction ( QIcon (
":/geoadvancededittool/images/AdvancedEditAction.png" ), tr ( "advanced edit
polygons tool" ), this);
m_ptAdvancedEditAction->setCheckable ( true );
m_ptAdvancedEditAction->setActionGroup (
m_ptInterface->actionMoveFeature()->actionGroup() );
m_ptInterface->digitizeToolBar()->addAction (
m_ptAdvancedEditAction );
connect( m_ptAdvancedEditAction, SIGNAL( triggered() ), this,
SLOT( advancedEditActivated() ) );
setAction( m_ptAdvancedEditAction );
//--------------------------------------------------------------------------
activateDeactivateTool ( m_ptInterface->activeLayer() );
connect ( m_ptInterface, SIGNAL( currentLayerChanged (
QgsMapLayer* ) ), this, SLOT ( activateDeactivateTool( QgsMapLayer * ) ) );
connect ( m_ptInterface->actionToggleEditing(), SIGNAL(
triggered() ), this, SLOT ( activateDeactivateTool() ) );
}
MapToolAdvancedEditPolygons::~MapToolAdvancedEditPolygons()
{
m_ptInterface->digitizeToolBar()->removeAction (
m_ptAdvancedEditAction );
if ( m_ptAdvancedEditAction )
delete m_ptAdvancedEditAction;
}
void MapToolAdvancedEditPolygons::advancedEditActivated()
{
// Installation du map tool
m_ptInterface->mapCanvas()->setMapTool( this );
// Définition du curseur
m_ptInterface->mapCanvas()->setCursor( QCursor( Qt::CrossCursor
) );
}
void MapToolAdvancedEditPolygons::activateDeactivateTool( QgsMapLayer
*ptMapLayer )
{
deselectFeature ();
QgsVectorLayer *ptVLayer = qobject_cast<QgsVectorLayer *>(
ptMapLayer );
if ( ptVLayer && ptVLayer->isEditable() && (
ptVLayer->geometryType() == QGis::Polygon ) )
m_ptAdvancedEditAction->setEnabled ( true );
else
{
m_ptAdvancedEditAction->setEnabled ( false );
m_ptInterface->mapCanvas ()->mapTool () == this )
{
// désactiver l'outil
m_ptInterface->mapCanvas ()->unsetMapTool (
this );
// activer l'outil de déplacement dans la
carte "Pan Map"
m_ptInterface->actionPan()->trigger();
}
}
void MapToolAdvancedEditPolygons::activateDeactivateTool()
{
activateDeactivateTool(
m_ptInterface->mapCanvas()->currentLayer() );
}
private:
QgisInterface *m_ptInterface;
QAction *m_ptAdvancedEditAction;
};_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer