Skip to content

Commit

Permalink
Move QGISDEBUG definition to header
Browse files Browse the repository at this point in the history
Because having it as a compiler flag means that when compiling a dependant application we need to have extra knowledge of this setting at compile time of the dependant application.

If this is not guaranteed (and the dependant application is compiled without QGISDEBUG while libqgis_core.so is compiled with QGISDEBUG) will result in different class definitions being found in header and library. For example for the optional QgsCoordinateTransform::mHasContext member. This in turn leads to crashes with funky traces and no chance to find out what's going on.
  • Loading branch information
m-kuhn committed Jan 4, 2018
1 parent c8cb68a commit ab05bfb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,9 @@ ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")

IF (CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
MESSAGE (STATUS "Debug output enabled")
ADD_DEFINITIONS(-DQGISDEBUG=1)
SET(QGISDEBUG TRUE)
ELSE (CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
SET(QGISDEBUG FALSE)
ENDIF (CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)

IF(MSVC)
Expand Down
2 changes: 2 additions & 0 deletions cmake_templates/qgsconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@

#cmakedefine USE_THREAD_LOCAL

#cmakedefine QGISDEBUG

#endif

1 change: 1 addition & 0 deletions src/core/qgscoordinatetransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <QExplicitlySharedDataPointer>

#include "qgsconfig.h"
#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgscoordinatereferencesystem.h"
Expand Down
1 change: 1 addition & 0 deletions src/providers/postgres/qgspostgresconn.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "qgis.h"
#include "qgsdatasourceuri.h"
#include "qgswkbtypes.h"
#include "qgsconfig.h"

extern "C"
{
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wms/qgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, in
int col0, col1, row0, row1;
tm->viewExtentIntersection( viewExtent, tml, col0, row0, col1, row1 );

#if QGISDEBUG
#ifdef QGISDEBUG
int n = ( col1 - col0 + 1 ) * ( row1 - row0 + 1 );
QgsDebugMsg( QString( "tile number: %1x%2 = %3" ).arg( col1 - col0 + 1 ).arg( row1 - row0 + 1 ).arg( n ) );
if ( n > 256 )
Expand Down

1 comment on commit ab05bfb

@3nids
Copy link
Member

@3nids 3nids commented on ab05bfb Jan 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting some warning for unused variables

screen shot 2018-01-04 at 14 13 02

Please sign in to comment.