From 24603eafd83df04c6497fbc2356d18ea936fe5f4 Mon Sep 17 00:00:00 2001 From: "Juergen E. Fischer" Date: Sat, 18 Aug 2012 19:43:53 +0200 Subject: [PATCH] handle min()/max() macros offending std::numeric_limits::min()/max() on MSVC in one spot --- CMakeLists.txt | 2 ++ python/CMakeLists.txt | 7 ------- src/app/qgsattributetabledialog.cpp | 2 +- src/core/gps/qgsgpsdetector.h | 9 --------- src/core/raster/qgsrasterlayer.cpp | 17 +++++------------ 5 files changed, 8 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80e9484ccf4..f763a88c854 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -289,6 +289,8 @@ ENDIF (CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo IF(MSVC) SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DQGISDEBUG=1") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQGISDEBUG=1") + # disable macros that offend std::numeric_limits::min()/max() + ADD_DEFINITIONS(-DNOMINMAX) ENDIF(MSVC) ############################################################# diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 4e3e8bd441f..1e7b9323a0f 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -39,13 +39,6 @@ INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} # qgsconfig.h, qgsversion.h ) - -# In Windef.h there are min() and max() macros that interfere with the usage -# of std::numeric_limits::min() and :max() in qgsrasterbands.h. -IF(MSVC) - ADD_DEFINITIONS(-DNOMINMAX) -ENDIF(MSVC) - IF(PYQT4_VERSION_NUM LESS 263680) # 0x040600 SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} PROXY_FACTORY) ENDIF(PYQT4_VERSION_NUM LESS 263680) diff --git a/src/app/qgsattributetabledialog.cpp b/src/app/qgsattributetabledialog.cpp index fdb8789e94b..8ec00d09f0b 100644 --- a/src/app/qgsattributetabledialog.cpp +++ b/src/app/qgsattributetabledialog.cpp @@ -707,7 +707,7 @@ void QgsAttributeTableDialog::on_mAddAttribute_clicked() mLayer->destroyEditCommand(); } // update model - a field has been added or updated - mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount() - 1, mModel->columnCount() - 1 ) );\ + mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount() - 1, mModel->columnCount() - 1 ) ); columnBoxInit(); } } diff --git a/src/core/gps/qgsgpsdetector.h b/src/core/gps/qgsgpsdetector.h index a6991d8a6d8..c8d52b3b07d 100644 --- a/src/core/gps/qgsgpsdetector.h +++ b/src/core/gps/qgsgpsdetector.h @@ -22,15 +22,6 @@ #include #include -#ifdef _MSC_VER -// qextserialport.h includes windows.h, -// which defines min()/max() macros w/o NOMINMAX, -// which in turn breaks limits std::numeric_limits::min()/max() -#ifndef NOMINMAX -#define NOMINMAX -#endif -#endif - #include "qextserialport.h" class QgsGPSConnection; diff --git a/src/core/raster/qgsrasterlayer.cpp b/src/core/raster/qgsrasterlayer.cpp index 253a18b2c25..38467921306 100644 --- a/src/core/raster/qgsrasterlayer.cpp +++ b/src/core/raster/qgsrasterlayer.cpp @@ -82,14 +82,6 @@ email : tim at linfiniti.com typedef void buildsupportedrasterfilefilter_t( QString & theFileFiltersString ); typedef bool isvalidrasterfilename_t( QString const & theFileNameQString, QString & retErrMsg ); -// workaround for MSVC compiler which already has defined macro max -// that interferes with calling std::numeric_limits::max -#ifdef _MSC_VER -# ifdef max -# undef max -# endif -#endif - // Comparison value for equality; i.e., we shouldn't directly compare two // floats so it's better to take their difference and see if they're within // a certain range -- in this case twenty times the smallest value that @@ -339,6 +331,7 @@ int QgsRasterLayer::bandNumber( QString const & theBandName ) const return 0; //no band was found } +#if 0 /** * Private method to calculate statistics for a band. Populates rasterStatsMemArray. * Calculates: @@ -358,7 +351,6 @@ int QgsRasterLayer::bandNumber( QString const & theBandName ) const * @sa RasterBandStats * @note This is a cpu intensive and slow task! */ -/* const QgsRasterBandStats QgsRasterLayer::bandStatistics( int theBandNo ) { QgsDebugMsg( "theBandNo = " + QString::number( theBandNo ) ); @@ -431,7 +423,7 @@ const QgsRasterBandStats QgsRasterLayer::bandStatistics( QString const & theBand return QgsRasterBandStats(); // return a null one } -*/ +#endif QString QgsRasterLayer::buildPyramids( RasterPyramidList const & theRasterPyramidList, QString const & theResamplingMethod, bool theTryInternalFlag ) @@ -2234,8 +2226,8 @@ void QgsRasterLayer::setRenderer( QgsRasterRenderer* theRenderer ) mPipe.set( theRenderer ); } +#if 0 // not sure if we want it -/* void QgsRasterLayer::setResampleFilter( QgsRasterResampleFilter* resampleFilter ) { QgsDebugMsg( "Entered" ); @@ -2246,7 +2238,8 @@ void QgsRasterLayer::setResampleFilter( QgsRasterResampleFilter* resampleFilter QgsDebugMsg( "Cannot set resample filter." ); } } -*/ +#endif + void QgsRasterLayer::showProgress( int theValue ) { emit progressUpdate( theValue );