Skip to content
Permalink
Browse files

Fix tracing

  • Loading branch information
m-kuhn committed Sep 13, 2017
1 parent 1d702d2 commit dded4ba1982a157030e1c44988bf1e668ea58644
Showing with 11 additions and 8 deletions.
  1. +9 −6 src/gui/qgsmapcanvastracer.cpp
  2. +2 −2 src/gui/qgsmapcanvastracer.h
@@ -24,16 +24,13 @@

#include <QAction>

QHash<QgsMapCanvas*, QgsMapCanvasTracer*> QgsMapCanvasTracer::sTracers;


QgsMapCanvasTracer::QgsMapCanvasTracer( QgsMapCanvas* canvas, QgsMessageBar* messageBar )
: mCanvas( canvas )
, mMessageBar( messageBar )
, mLastMessage( nullptr )
, mActionEnableTracing( nullptr )
{
sTracers.insert( canvas, this );
tracers().insert( mCanvas, this );

// when things change we just invalidate the graph - and set up new parameters again only when necessary
connect( canvas, SIGNAL( destinationCrsChanged() ), this, SLOT( invalidateGraph() ) );
@@ -49,12 +46,12 @@ QgsMapCanvasTracer::QgsMapCanvasTracer( QgsMapCanvas* canvas, QgsMessageBar* mes

QgsMapCanvasTracer::~QgsMapCanvasTracer()
{
sTracers.remove( mCanvas );
tracers().remove( mCanvas );
}

QgsMapCanvasTracer* QgsMapCanvasTracer::tracerForCanvas( QgsMapCanvas* canvas )
{
return sTracers.value( canvas, 0 );
return tracers().value( canvas );
}

void QgsMapCanvasTracer::reportError( QgsTracer::PathError err, bool addingVertex )
@@ -137,3 +134,9 @@ void QgsMapCanvasTracer::onCurrentLayerChanged()
if ( mCanvas->snappingUtils()->snapToMapMode() == QgsSnappingUtils::SnapCurrentLayer )
invalidateGraph();
}

QHash<QgsMapCanvas*, QgsMapCanvasTracer*> &QgsMapCanvasTracer::tracers()
{
static QHash<QgsMapCanvas*, QgsMapCanvasTracer*> sTracers;
return sTracers;
}
@@ -67,13 +67,13 @@ class GUI_EXPORT QgsMapCanvasTracer : public QgsTracer
void onCurrentLayerChanged();

private:
static QHash<QgsMapCanvas*, QgsMapCanvasTracer*>& tracers();

QgsMapCanvas* mCanvas;
QgsMessageBar* mMessageBar;
QgsMessageBarItem* mLastMessage;

QAction* mActionEnableTracing;

static QHash<QgsMapCanvas*, QgsMapCanvasTracer*> sTracers;
};

#endif // QGSMAPCANVASTRACER_H

0 comments on commit dded4ba

Please sign in to comment.
You can’t perform that action at this time.