Skip to content

Commit

Permalink
fixed ticket 90 (post grass edit right click crash)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5676 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Aug 8, 2006
1 parent 6a26b12 commit 444c1c0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
14 changes: 14 additions & 0 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -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();
Expand Down
15 changes: 11 additions & 4 deletions src/plugins/grass/qgsgrassedit.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -927,6 +927,10 @@ QgsGrassEdit::~QgsGrassEdit()
delete mRubberBandLine;
delete mRubberBandIcon;
delete mCanvasEdit;

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

mCanvas->refresh();
}

Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
}


Expand Down
4 changes: 4 additions & 0 deletions src/plugins/grass/qgsgrassedit.h
Expand Up @@ -38,6 +38,7 @@ class QCloseEvent;
class QgsRubberBand;
class QgsVertexMarker;
class QgsVectorLayer;
class QgsMapTool;
class QgsGrassEditLayer;
class QgsGrassAttributes;

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

// Current map tool
QgsMapTool *mMapTool;

// Is projection enabled?
bool mProjectionEnabled;

Expand Down

0 comments on commit 444c1c0

Please sign in to comment.