Skip to content

Commit

Permalink
Add a QgsDebugCall macro to trace entering/leaving functions
Browse files Browse the repository at this point in the history
Replace manual debugging lines used for the same purpose in a couple
of implementation files for node tool.
  • Loading branch information
Sandro Santilli committed May 28, 2013
1 parent c510c44 commit 20c729a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/app/nodetool/qgsmaptoolnodetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ void QgsMapToolNodeTool::canvasMoveEvent( QMouseEvent * e )

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

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

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

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

Expand Down
12 changes: 6 additions & 6 deletions src/app/nodetool/qgsselectedfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;

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

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

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

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

if ( !mGeometry )
{
Expand Down
18 changes: 18 additions & 0 deletions src/core/qgslogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.