Skip to content

Commit

Permalink
add QGISDEPRECATED macro and fix a bunch of warnings
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@15197 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Feb 18, 2011
1 parent ccdda6b commit 1edaeca
Show file tree
Hide file tree
Showing 42 changed files with 340 additions and 274 deletions.
11 changes: 11 additions & 0 deletions cmake/SIPMacros.cmake
Expand Up @@ -85,6 +85,17 @@ MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
ENDIF( ${CONCAT_NUM} LESS ${SIP_CONCAT_PARTS} )
ENDFOREACH(CONCAT_NUM RANGE 0 ${SIP_CONCAT_PARTS} )

# Suppress warnings
IF(MSVC AND PEDANTIC)
# 4996 deprecation warnings (bindings re-export deprecated methods)
# 4701 potentially uninitialized variable used (sip generated code)
# 4702 unreachable code (sip generated code)
ADD_DEFINITIONS( /wd4996 /wd4701 /wd4702 )
ELSE(MSVC)
# disable all warnings
ADD_DEFINITIONS( -w )
ENDIF(MSVC)

ADD_CUSTOM_COMMAND(
OUTPUT ${_sip_output_files}
COMMAND ${CMAKE_COMMAND} -E echo ${message}
Expand Down
18 changes: 18 additions & 0 deletions python/core/conversions.sip
Expand Up @@ -36,6 +36,8 @@ template <TYPE>
#include <QVector>
#if (SIP_VERSION >= 0x040900)
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
#endif
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
#endif
%End
Expand Down Expand Up @@ -116,6 +118,8 @@ template <TYPE>
#include <QVector>
#if (SIP_VERSION >= 0x040900)
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
#endif
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
#endif
%End
Expand Down Expand Up @@ -274,6 +278,8 @@ template <TYPE>
#include <QSet>
#if (SIP_VERSION >= 0x040900)
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
#endif
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
#endif
%End
Expand Down Expand Up @@ -329,6 +335,8 @@ template <TYPE>
#include <QSet>
#if (SIP_VERSION >= 0x040900)
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
#endif
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
#endif
%End
Expand Down Expand Up @@ -404,6 +412,8 @@ template<TYPE>
#include <QMap>
#if (SIP_VERSION >= 0x040900)
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
#endif
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
#endif
%End
Expand Down Expand Up @@ -525,6 +535,8 @@ template<TYPE>
#include <QMap>
#if (SIP_VERSION >= 0x040900)
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
#endif
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
#endif
%End
Expand Down Expand Up @@ -630,6 +642,8 @@ template<TYPE1, TYPE2>
#include <QMap>
#if (SIP_VERSION >= 0x040900)
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
#endif
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
#endif
%End
Expand Down Expand Up @@ -842,6 +856,8 @@ template<double, TYPE2>
#include <QMultiMap>
#if (SIP_VERSION >= 0x040900)
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
#endif
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
#endif
%End
Expand Down Expand Up @@ -964,6 +980,8 @@ template<double, TYPE2>
#include <QMap>
#if (SIP_VERSION >= 0x040900)
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
#endif
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
#endif
%End
Expand Down
2 changes: 0 additions & 2 deletions python/pyspatialite/src/statement.c
Expand Up @@ -490,8 +490,6 @@ static int pysqlite_check_remaining_sql(const char* tail)

pos++;
}

return 0;
}

PyTypeObject pysqlite_StatementType = {
Expand Down
9 changes: 9 additions & 0 deletions src/analysis/CMakeLists.txt
Expand Up @@ -42,6 +42,15 @@ ADD_FLEX_FILES_PREFIX(QGIS_ANALYSIS_SRCS raster raster/qgsrastercalclexer.ll)

ADD_BISON_FILES_PREFIX(QGIS_ANALYSIS_SRCS raster raster/qgsrastercalcparser.yy)

IF (MSVC AND PEDANTIC)
# disable warnings
# 4065 switch with default and no case
# 4702 unreachable code
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_BINARY_DIR}/src/analysis/qgsrastercalcparser.cpp
PROPERTIES COMPILE_FLAGS "-wd4065 -wd4702")
ENDIF (MSVC AND PEDANTIC)

SET(QGIS_ANALYSIS_MOC_HDRS
)

Expand Down
3 changes: 3 additions & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -321,6 +321,9 @@ QT4_WRAP_CPP(QGIS_APP_MOC_SRCS ${QGIS_APP_MOC_HDRS})
IF (WIN32)
IF (MSVC)
SET (QGIS_APP_SRCS ${QGIS_APP_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/qgis_win32.rc)

# disable deprecation warnings
SET_SOURCE_FILES_PROPERTIES(qgisappinterface.cpp PROPERTIES COMPILE_FLAGS /wd4996)
ELSE(MSVC)

# Icon for windows MINGW
Expand Down
24 changes: 12 additions & 12 deletions src/app/legend/qgslegend.cpp
Expand Up @@ -626,7 +626,7 @@ void QgsLegend::addLayer( QgsMapLayer * layer )

setItemExpanded( llayer, true );

refreshLayerSymbology( layer->getLayerID() );
refreshLayerSymbology( layer->id() );

updateMapCanvasLayerSet();

Expand Down Expand Up @@ -738,7 +738,7 @@ void QgsLegend::removeGroup( QgsLegendGroup *lg )
QgsLegendGroup *cg = dynamic_cast<QgsLegendGroup *>( child );

if ( cl )
QgsMapLayerRegistry::instance()->removeMapLayer( cl->layer()->getLayerID() );
QgsMapLayerRegistry::instance()->removeMapLayer( cl->layer()->id() );
else if ( cg )
removeGroup( cg );

Expand All @@ -755,7 +755,7 @@ void QgsLegend::moveLayer( QgsMapLayer *ml, int groupIndex )
if ( !ml )
return;

QgsLegendLayer *layer = findLegendLayer( ml->getLayerID() );
QgsLegendLayer *layer = findLegendLayer( ml->id() );
if ( !layer )
return;

Expand Down Expand Up @@ -915,7 +915,7 @@ bool QgsLegend::writeXML( QList<QTreeWidgetItem *> items, QDomNode &node, QDomDo
QDomElement legendlayerfilenode = document.createElement( "legendlayerfile" );

// layer id
legendlayerfilenode.setAttribute( "layerid", layer->getLayerID() );
legendlayerfilenode.setAttribute( "layerid", layer->id() );
layerfilegroupnode.appendChild( legendlayerfilenode );

// visible flag
Expand Down Expand Up @@ -1022,7 +1022,7 @@ bool QgsLegend::readXML( QgsLegendGroup *parent, const QDomNode &node )
}

// load symbology
refreshLayerSymbology( currentLayer->layer()->getLayerID() );
refreshLayerSymbology( currentLayer->layer()->id() );

if ( isOpen )
{
Expand Down Expand Up @@ -1101,7 +1101,7 @@ QgsLegendLayer* QgsLegend::findLegendLayer( const QString& layerKey )
theLegendLayer = dynamic_cast<QgsLegendLayer *>( theItem );
if ( theLegendLayer ) //item is a legend layer
{
if ( theLegendLayer->layer()->getLayerID() == layerKey )
if ( theLegendLayer->layer()->id() == layerKey )
{
return theLegendLayer;
}
Expand Down Expand Up @@ -1221,7 +1221,7 @@ QList< GroupLayerInfo > QgsLegend::groupLayerRelationship()
if ( lLayer->layer() )
{
QList<QString> layerList;
layerList.push_back( lLayer->layer()->getLayerID() );
layerList.push_back( lLayer->layer()->id() );
groupLayerList.push_back( qMakePair( QString(), layerList ) );
}
}
Expand All @@ -1240,7 +1240,7 @@ QList< GroupLayerInfo > QgsLegend::groupLayerRelationship()
{
if ( lLayer->layer() )
{
layerList.push_back( lLayer->layer()->getLayerID() );
layerList.push_back( lLayer->layer()->id() );
}
}

Expand Down Expand Up @@ -1449,7 +1449,7 @@ QStringList QgsLegend::layerIDs()
if ( ll )
{
QgsMapLayer *lyr = ll->layer();
layers.push_front( lyr->getLayerID() );
layers.push_front( lyr->id() );
}
}

Expand Down Expand Up @@ -1729,8 +1729,8 @@ void QgsLegend::legendLayerStretchUsingCurrentExtent()
}

layer->setMinimumMaximumUsingLastExtent();
layer->setCacheImage(NULL);
refreshLayerSymbology( layer->getLayerID() );
layer->setCacheImage( NULL );
refreshLayerSymbology( layer->id() );
mMapCanvas->refresh();
}
}
Expand Down Expand Up @@ -1847,7 +1847,7 @@ void QgsLegend::removeSelectedLayers()
QgsLegendLayer *ll = dynamic_cast<QgsLegendLayer *>( item );
if ( ll && ll->layer() )
{
QgsMapLayerRegistry::instance()->removeMapLayer( ll->layer()->getLayerID() );
QgsMapLayerRegistry::instance()->removeMapLayer( ll->layer()->id() );
continue;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgssnappingdialog.cpp
Expand Up @@ -191,7 +191,7 @@ void QgsSnappingDialog::update()
mLayerTreeWidget->setItemWidget( item, 5, cbxAvoidIntersection );
}

int idx = layerIdList.indexOf( currentVectorLayer->getLayerID() );
int idx = layerIdList.indexOf( currentVectorLayer->id() );
if ( idx < 0 )
{
// no settings for this layer yet
Expand All @@ -218,7 +218,7 @@ void QgsSnappingDialog::update()
cbxUnits->setCurrentIndex( toleranceUnitList[idx].toInt() );
if ( cbxAvoidIntersection )
{
cbxAvoidIntersection->setChecked( avoidIntersectionsList.contains( currentVectorLayer->getLayerID() ) );
cbxAvoidIntersection->setChecked( avoidIntersectionsList.contains( currentVectorLayer->id() ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerattributetable.cpp
Expand Up @@ -231,7 +231,7 @@ bool QgsComposerAttributeTable::writeXML( QDomElement& elem, QDomDocument & doc
}
if ( mVectorLayer )
{
composerTableElem.setAttribute( "vectorLayer", mVectorLayer->getLayerID() );
composerTableElem.setAttribute( "vectorLayer", mVectorLayer->id() );
}

//display attributes
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgslegendmodel.cpp
Expand Up @@ -242,7 +242,7 @@ int QgsLegendModel::addRasterLayerItem( QStandardItem* layerItem, QgsMapLayer* r
{
currentSymbolItem->setIcon( QIcon( rasterLayer->legendAsPixmap( true ) ) );
}
currentSymbolItem->setLayerID( rasterLayer->getLayerID() );
currentSymbolItem->setLayerID( rasterLayer->id() );
int currentRowCount = layerItem->rowCount();
layerItem->setChild( currentRowCount, 0, currentSymbolItem );

Expand Down Expand Up @@ -338,7 +338,7 @@ void QgsLegendModel::addLayer( QgsMapLayer* theMapLayer )
}

QgsComposerLayerItem* layerItem = new QgsComposerLayerItem( theMapLayer->name() );
layerItem->setLayerID( theMapLayer->getLayerID() );
layerItem->setLayerID( theMapLayer->id() );
layerItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );

invisibleRootItem()->setChild( invisibleRootItem()->rowCount(), layerItem );
Expand Down
14 changes: 14 additions & 0 deletions src/core/qgis.h
Expand Up @@ -189,4 +189,18 @@ const double DEFAULT_LINE_WIDTH = 0.26;
#endif
#endif

#ifndef QGISDEPRECATED
#ifndef Q_MOC_RUN
#ifdef _MSC_VER
# define QGISDEPRECATED __declspec(deprecated)
#elif __GNUC__
# define QGISDEPRECATED __attribute__((__deprecated__))
#else
# define QGISDEPRECATED
#endif
#else
#define QGISDEPRECATED
#endif
#endif

#endif
4 changes: 3 additions & 1 deletion src/core/qgsapplication.h
Expand Up @@ -18,6 +18,8 @@

#include <QApplication>

#include <qgis.h>

/** \ingroup core
* Extends QApplication to provide access to QGIS specific resources such
* as theme paths, database paths etc.
Expand Down Expand Up @@ -111,7 +113,7 @@ class CORE_EXPORT QgsApplication: public QApplication

//! Returns the paths to svg applications svg directory.
//! @deprecated since 1.4
static const QString svgPath();
QGISDEPRECATED static const QString svgPath();

//! Returns the path to the application prefix directory.
static const QString prefixPath();
Expand Down
12 changes: 6 additions & 6 deletions src/core/qgslabel.h
Expand Up @@ -103,11 +103,11 @@ class CORE_EXPORT QgsLabel
* \param rasterScaleFactor raster scale
* \deprecated
*/
void renderLabel( QPainter* painter, const QgsRectangle& viewExtent,
QgsCoordinateTransform* coordinateTransform,
const QgsMapToPixel *transform,
QgsFeature &feature, bool selected, QgsLabelAttributes *classAttributes = 0,
double sizeScale = 1., double rasterScaleFactor = 1.0 )
QGISDEPRECATED void renderLabel( QPainter* painter, const QgsRectangle& viewExtent,
QgsCoordinateTransform* coordinateTransform,
const QgsMapToPixel *transform,
QgsFeature &feature, bool selected, QgsLabelAttributes *classAttributes = 0,
double sizeScale = 1., double rasterScaleFactor = 1.0 )
{
QgsRenderContext r;
r.setExtent( viewExtent );
Expand Down Expand Up @@ -148,7 +148,7 @@ class CORE_EXPORT QgsLabel
/** Pointer to default attributes.
* @deprecated in version 2 as it is badly named. Rather use attributes.
* @see labelAttributes method rather */
QgsLabelAttributes *layerAttributes( void );
QGISDEPRECATED QgsLabelAttributes *layerAttributes( void );

/** Pointer to default attributes.
* @note this replaces the to-be-deprecated layerAttributes method.
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsmaplayer.h
Expand Up @@ -25,6 +25,7 @@
#include <QVariant>
#include <QImage>

#include "qgis.h"
#include "qgsrectangle.h"

class QgsRenderContext;
Expand Down Expand Up @@ -75,7 +76,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
/** Get this layer's unique ID, this ID is used to access this layer from map layer registry
* @deprecated use id()
**/
QString getLayerID() const { return id(); }
QGISDEPRECATED QString getLayerID() const { return id(); }

/** Set the display name of the layer
* @param name New name for the layer
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsmaprenderer.h
Expand Up @@ -135,7 +135,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject

//! Return the measuring object
//! @deprecated
QgsDistanceArea* distanceArea() { return mDistArea; }
QGISDEPRECATED QgsDistanceArea *distanceArea() { return mDistArea; }
QGis::UnitType mapUnits() const;
void setMapUnits( QGis::UnitType u );

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsoverlayobject.h
Expand Up @@ -43,11 +43,11 @@ class CORE_EXPORT QgsOverlayObject
/**Returns the feature geometry in geos format. The calling function does _not_ take
ownership of the generated object. The geometry is in map coordinates
@deprecated Please use geometry() and QgsGeometry::asGeos instead*/
GEOSGeometry* getGeosGeometry();
QGISDEPRECATED GEOSGeometry* getGeosGeometry();
/**Feature geometry is released when object is destructed so this function is empty.
* @deprecated nop
*/
void releaseGeosGeometry( GEOSGeometry *the_geom ) { Q_UNUSED( the_geom ); }
QGISDEPRECATED void releaseGeosGeometry( GEOSGeometry *the_geom ) { Q_UNUSED( the_geom ); }

//getters
int width() const {return mWidth;}
Expand Down

0 comments on commit 1edaeca

Please sign in to comment.