Skip to content
Permalink
Browse files
fixed ticket 90 (post grass edit right click crash)
git-svn-id: http://svn.osgeo.org/qgis/trunk@5676 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Aug 8, 2006
1 parent d805cd9 commit 0d3bef6990c59e3cf26585a592ef4a4462bd0113
Showing with 36 additions and 4 deletions.
  1. +14 −0 src/gui/qgsmapcanvas.cpp
  2. +7 −0 src/gui/qgsmapcanvas.h
  3. +11 −4 src/plugins/grass/qgsgrassedit.cpp
  4. +4 −0 src/plugins/grass/qgsgrassedit.h
@@ -823,6 +823,20 @@ void QgsMapCanvas::setMapTool(QgsMapTool* tool)

} // setMapTool

void QgsMapCanvas::unsetMapTool(QgsMapTool* tool)
{
if (mMapTool && mMapTool == tool)
{
mMapTool->deactivate();
mMapTool = NULL;
}

if ( mLastNonZoomMapTool && mLastNonZoomMapTool == tool)
{
mLastNonZoomMapTool->deactivate(); // ? necessary
mLastNonZoomMapTool = NULL;
}
}

/** Write property of QColor bgColor. */
void QgsMapCanvas::setCanvasColor(const QColor & theColor)
@@ -114,6 +114,13 @@ class QgsMapCanvas : public Q3CanvasView

/** \brief Sets the map tool currently being used on the canvas */
void setMapTool(QgsMapTool* mapTool);

/** \brief Unset the current mapset tool or last non zoom tool if
* it the same as passed map tool pointer. The tool is not
* referenced/used any more, but the instance is not deleted
* by this method.
*/
void unsetMapTool(QgsMapTool* mapTool);

/**Returns the currently active tool*/
QgsMapTool* mapTool();
@@ -106,7 +106,7 @@ bool QgsGrassEdit::mRunning = false;

QgsGrassEdit::QgsGrassEdit ( QgisApp *qgisApp, QgisIface *iface,
QWidget * parent, Qt::WFlags f )
:QMainWindow(parent,f), QgsGrassEditBase ()
:QMainWindow(parent,f), QgsGrassEditBase (), mMapTool(0)
{
#ifdef QGISDEBUG
std::cerr << "QgsGrassEdit()" << std::endl;
@@ -193,7 +193,7 @@ void QgsGrassEdit::keyPress(QKeyEvent *e)
QgsGrassEdit::QgsGrassEdit ( QgisApp *qgisApp, QgisIface *iface,
QgsGrassProvider *provider,
QWidget * parent, Qt::WFlags f )
:QMainWindow(parent, 0, f), QgsGrassEditBase ()
:QMainWindow(parent, 0, f), QgsGrassEditBase (), mMapTool(0)
{
#ifdef QGISDEBUG
std::cerr << "QgsGrassEdit()" << std::endl;
@@ -927,6 +927,10 @@ QgsGrassEdit::~QgsGrassEdit()
delete mRubberBandLine;
delete mRubberBandIcon;
delete mCanvasEdit;

if ( mMapTool ) mCanvas->unsetMapTool ( mMapTool );
// TODO: delete tool? Probably

mCanvas->refresh();
}

@@ -1235,7 +1239,10 @@ void QgsGrassEdit::startTool(int tool)
displayElement ( mSelectedLine, mSymb[mLineSymb[mSelectedLine]], mSize );

// close old tool by setting NULL tool
mCanvas->setMapTool(NULL);
// TODO: delete old tool? (check in set/unsetMapTool canvas methods)
if ( mMapTool ) mCanvas->unsetMapTool ( mMapTool );
mCanvas->setMapTool(NULL); // ? necessary
mMapTool = NULL;

// All necessary data were written -> reset mEditPoints etc.
Vect_reset_line ( mEditPoints );
@@ -1321,7 +1328,7 @@ void QgsGrassEdit::startTool(int tool)
// assign newly created tool to map canvas
// canvas will take care of destroying it
mCanvas->setMapTool(t);

mMapTool = t;
}


@@ -38,6 +38,7 @@ class QCloseEvent;
class QgsRubberBand;
class QgsVertexMarker;
class QgsVectorLayer;
class QgsMapTool;
class QgsGrassEditLayer;
class QgsGrassAttributes;

@@ -437,6 +438,9 @@ public slots:
QAction *mEditAttributesAction;
QAction *mCloseEditAction;

// Current map tool
QgsMapTool *mMapTool;

// Is projection enabled?
bool mProjectionEnabled;

0 comments on commit 0d3bef6

Please sign in to comment.