Skip to content

Commit

Permalink
Solved problems with destruction of map tools - canvas mustn't be del…
Browse files Browse the repository at this point in the history
…eted before map tool,

however in Python the destruction had to be done explicitly to acheive right order.
New solution is that QgsMapTool is derived from QObject and on construction, QgsMapCanvas
is set as its parent. This way canvas is always deleted after deletion of map tools.

Also, because of this, I've divided QgsMeasure to QgsMeasureTool and QgsMeasureDialog
(problem with 2 parents with QObject as a base).


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6908 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Apr 23, 2007
1 parent aba4b3c commit 301cd6c
Show file tree
Hide file tree
Showing 12 changed files with 608 additions and 489 deletions.
4 changes: 2 additions & 2 deletions python/gui/qgsmaptool.sip
@@ -1,5 +1,5 @@

class QgsMapTool
class QgsMapTool : QObject
{
%TypeHeaderCode
#include <qgsmaptool.h>
Expand Down Expand Up @@ -54,7 +54,7 @@ class QgsMapTool
protected:

//! constructor takes map canvas as a parameter
QgsMapTool(QgsMapCanvas* canvas);
QgsMapTool(QgsMapCanvas* canvas /TransferThis/);

//! transformation from screen coordinates to map coordinates
QgsPoint toMapCoords(const QPoint& point);
Expand Down
5 changes: 3 additions & 2 deletions src/app/CMakeLists.txt
Expand Up @@ -31,7 +31,8 @@ qgsmaptoolidentify.cpp
qgsmaptoolselect.cpp
qgsmaptoolvertexedit.cpp
qgsmarkerdialog.cpp
qgsmeasure.cpp
qgsmeasuredialog.cpp
qgsmeasuretool.cpp
qgsnewhttpconnection.cpp
qgsnumericsortlistviewitem.cpp
qgsoptions.cpp
Expand Down Expand Up @@ -100,7 +101,7 @@ qgsludialog.h
qgsmaplayerinterface.h
qgsmaptoolidentify.h
qgsmarkerdialog.h
qgsmeasure.h
qgsmeasuredialog.h
qgsnewhttpconnection.h
qgsoptions.h
qgspastetransformations.h
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgisapp.cpp
Expand Up @@ -150,7 +150,7 @@
#include "qgsmaptoolselect.h"
#include "qgsmaptoolvertexedit.h"
#include "qgsmaptoolzoom.h"
#include "qgsmeasure.h"
#include "qgsmeasuretool.h"

//
// Conditional Includes
Expand Down Expand Up @@ -1203,9 +1203,9 @@ void QgisApp::createCanvas()
mMapTools.mPan->setAction(mActionPan);
mMapTools.mIdentify = new QgsMapToolIdentify(mMapCanvas);
mMapTools.mIdentify->setAction(mActionIdentify);
mMapTools.mMeasureDist = new QgsMeasure(FALSE /* area */, mMapCanvas);
mMapTools.mMeasureDist = new QgsMeasureTool(mMapCanvas, FALSE /* area */);
mMapTools.mMeasureDist->setAction(mActionMeasure);
mMapTools.mMeasureArea = new QgsMeasure(TRUE /* area */, mMapCanvas);
mMapTools.mMeasureArea = new QgsMeasureTool(mMapCanvas, TRUE /* area */);
mMapTools.mMeasureArea->setAction(mActionMeasureArea);
mMapTools.mCapturePoint = new QgsMapToolCapture(mMapCanvas, QgsMapToolCapture::CapturePoint);
mMapTools.mCapturePoint->setAction(mActionCapturePoint);
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolidentify.h
Expand Up @@ -37,7 +37,7 @@ class QgsVectorLayer;
- for vector layers shows feature attributes within search radius
(allows to edit values when vector layer is in editing mode)
*/
class QgsMapToolIdentify : public QObject, public QgsMapTool
class QgsMapToolIdentify : public QgsMapTool
{
Q_OBJECT;

Expand Down

0 comments on commit 301cd6c

Please sign in to comment.