Skip to content
Permalink
Browse files

Add a QgsDebugCall macro to trace entering/leaving functions

Replace manual debugging lines used for the same purpose in a couple
of implementation files for node tool.
  • Loading branch information
Sandro Santilli
Sandro Santilli committed May 28, 2013
1 parent c510c44 commit 20c729a3e915b8348eb730535d58cfcb5b4da51e
Showing with 26 additions and 9 deletions.
  1. +2 −3 src/app/nodetool/qgsmaptoolnodetool.cpp
  2. +6 −6 src/app/nodetool/qgsselectedfeature.cpp
  3. +18 −0 src/core/qgslogger.h
@@ -345,7 +345,7 @@ void QgsMapToolNodeTool::canvasMoveEvent( QMouseEvent * e )

void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
{
QgsDebugMsg( "Entering." );
QgsDebugCall;

QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );

@@ -473,12 +473,11 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
}
}
}
QgsDebugMsg( "Leaving." );
}

void QgsMapToolNodeTool::selectedFeatureDestroyed()
{
QgsDebugMsg( "Entered." );
QgsDebugCall;
mSelectedFeature = 0;
}

@@ -35,13 +35,13 @@ QgsSelectedFeature::QgsSelectedFeature( QgsFeatureId featureId,
, mRubberBand( 0 )
, mValidator( 0 )
{
QgsDebugMsg( "Entering." );
QgsDebugCall;
setSelectedFeature( featureId, vlayer, canvas );
}

QgsSelectedFeature::~QgsSelectedFeature()
{
QgsDebugMsg( "Entering." );
QgsDebugCall;

deleteVertexMap();

@@ -61,14 +61,14 @@ QgsSelectedFeature::~QgsSelectedFeature()

void QgsSelectedFeature::currentLayerChanged( QgsMapLayer *layer )
{
QgsDebugMsg( "Entering." );
QgsDebugCall;
if ( layer == mVlayer )
deleteLater();
}

void QgsSelectedFeature::updateGeometry( QgsGeometry *geom )
{
QgsDebugMsg( "Entering." );
QgsDebugCall;

delete mGeometry;

@@ -149,7 +149,7 @@ void QgsSelectedFeature::featureDeleted( QgsFeatureId fid )

void QgsSelectedFeature::geometryChanged( QgsFeatureId fid, QgsGeometry &geom )
{
QgsDebugMsg( "Entering." );
QgsDebugCall;

if ( !mVlayer || fid != mFeatureId )
return;
@@ -483,7 +483,7 @@ void QgsSelectedFeature::createVertexMapPoint()

void QgsSelectedFeature::createVertexMap()
{
QgsDebugMsg( "Entering." );
QgsDebugCall;

if ( !mGeometry )
{
@@ -30,7 +30,9 @@ class QFile;
if ( QgsLogger::debugLevel() >= (level) && (level) > 0 ) \
QgsLogger::debug(QString(str), (level), __FILE__, __FUNCTION__, __LINE__); \
}
#define QgsDebugCall QgsScopeLogger _qgsScopeLogger(__FILE__, __FUNCTION__, __LINE__)
#else
#define QgsDebugCall
#define QgsDebugMsg(str)
#define QgsDebugMsgLevel(str, level)
#endif
@@ -130,4 +132,20 @@ class CORE_EXPORT QgsLogger
static int sPrefixLength;
};

class QgsScopeLogger {
public:
QgsScopeLogger(const char* file, const char* func, int line)
: _file(file), _func(func), _line(line)
{
QgsLogger::debug("Entering.", 1, _file, _func, _line);
}
~QgsScopeLogger() {
QgsLogger::debug("Leaving.", 1, _file, _func, _line);
}
private:
const char *_file;
const char *_func;
int _line;
};

#endif

0 comments on commit 20c729a

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