Skip to content

Commit 007cc07

Browse files
author
jef
committed
add QGISDEPRECATED macro and fix a bunch of warnings
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15197 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 0a32a04 commit 007cc07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+340
-274
lines changed

cmake/SIPMacros.cmake

+11
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
8585
ENDIF( ${CONCAT_NUM} LESS ${SIP_CONCAT_PARTS} )
8686
ENDFOREACH(CONCAT_NUM RANGE 0 ${SIP_CONCAT_PARTS} )
8787

88+
# Suppress warnings
89+
IF(MSVC AND PEDANTIC)
90+
# 4996 deprecation warnings (bindings re-export deprecated methods)
91+
# 4701 potentially uninitialized variable used (sip generated code)
92+
# 4702 unreachable code (sip generated code)
93+
ADD_DEFINITIONS( /wd4996 /wd4701 /wd4702 )
94+
ELSE(MSVC)
95+
# disable all warnings
96+
ADD_DEFINITIONS( -w )
97+
ENDIF(MSVC)
98+
8899
ADD_CUSTOM_COMMAND(
89100
OUTPUT ${_sip_output_files}
90101
COMMAND ${CMAKE_COMMAND} -E echo ${message}

python/core/conversions.sip

+18
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ template <TYPE>
3636
#include <QVector>
3737
#if (SIP_VERSION >= 0x040900)
3838
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
39+
#endif
40+
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
3941
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
4042
#endif
4143
%End
@@ -116,6 +118,8 @@ template <TYPE>
116118
#include <QVector>
117119
#if (SIP_VERSION >= 0x040900)
118120
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
121+
#endif
122+
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
119123
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
120124
#endif
121125
%End
@@ -274,6 +278,8 @@ template <TYPE>
274278
#include <QSet>
275279
#if (SIP_VERSION >= 0x040900)
276280
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
281+
#endif
282+
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
277283
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
278284
#endif
279285
%End
@@ -329,6 +335,8 @@ template <TYPE>
329335
#include <QSet>
330336
#if (SIP_VERSION >= 0x040900)
331337
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
338+
#endif
339+
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
332340
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
333341
#endif
334342
%End
@@ -404,6 +412,8 @@ template<TYPE>
404412
#include <QMap>
405413
#if (SIP_VERSION >= 0x040900)
406414
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
415+
#endif
416+
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
407417
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
408418
#endif
409419
%End
@@ -525,6 +535,8 @@ template<TYPE>
525535
#include <QMap>
526536
#if (SIP_VERSION >= 0x040900)
527537
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
538+
#endif
539+
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
528540
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
529541
#endif
530542
%End
@@ -630,6 +642,8 @@ template<TYPE1, TYPE2>
630642
#include <QMap>
631643
#if (SIP_VERSION >= 0x040900)
632644
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
645+
#endif
646+
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
633647
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
634648
#endif
635649
%End
@@ -842,6 +856,8 @@ template<double, TYPE2>
842856
#include <QMultiMap>
843857
#if (SIP_VERSION >= 0x040900)
844858
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
859+
#endif
860+
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
845861
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
846862
#endif
847863
%End
@@ -964,6 +980,8 @@ template<double, TYPE2>
964980
#include <QMap>
965981
#if (SIP_VERSION >= 0x040900)
966982
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
983+
#endif
984+
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c00)
967985
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
968986
#endif
969987
%End

python/pyspatialite/src/statement.c

-2
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,6 @@ static int pysqlite_check_remaining_sql(const char* tail)
490490

491491
pos++;
492492
}
493-
494-
return 0;
495493
}
496494

497495
PyTypeObject pysqlite_StatementType = {

src/analysis/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ ADD_FLEX_FILES_PREFIX(QGIS_ANALYSIS_SRCS raster raster/qgsrastercalclexer.ll)
4242

4343
ADD_BISON_FILES_PREFIX(QGIS_ANALYSIS_SRCS raster raster/qgsrastercalcparser.yy)
4444

45+
IF (MSVC AND PEDANTIC)
46+
# disable warnings
47+
# 4065 switch with default and no case
48+
# 4702 unreachable code
49+
SET_SOURCE_FILES_PROPERTIES(
50+
${CMAKE_BINARY_DIR}/src/analysis/qgsrastercalcparser.cpp
51+
PROPERTIES COMPILE_FLAGS "-wd4065 -wd4702")
52+
ENDIF (MSVC AND PEDANTIC)
53+
4554
SET(QGIS_ANALYSIS_MOC_HDRS
4655
)
4756

src/app/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ QT4_WRAP_CPP(QGIS_APP_MOC_SRCS ${QGIS_APP_MOC_HDRS})
321321
IF (WIN32)
322322
IF (MSVC)
323323
SET (QGIS_APP_SRCS ${QGIS_APP_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/qgis_win32.rc)
324+
325+
# disable deprecation warnings
326+
SET_SOURCE_FILES_PROPERTIES(qgisappinterface.cpp PROPERTIES COMPILE_FLAGS /wd4996)
324327
ELSE(MSVC)
325328

326329
# Icon for windows MINGW

src/app/legend/qgslegend.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ void QgsLegend::addLayer( QgsMapLayer * layer )
626626

627627
setItemExpanded( llayer, true );
628628

629-
refreshLayerSymbology( layer->getLayerID() );
629+
refreshLayerSymbology( layer->id() );
630630

631631
updateMapCanvasLayerSet();
632632

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

740740
if ( cl )
741-
QgsMapLayerRegistry::instance()->removeMapLayer( cl->layer()->getLayerID() );
741+
QgsMapLayerRegistry::instance()->removeMapLayer( cl->layer()->id() );
742742
else if ( cg )
743743
removeGroup( cg );
744744

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

758-
QgsLegendLayer *layer = findLegendLayer( ml->getLayerID() );
758+
QgsLegendLayer *layer = findLegendLayer( ml->id() );
759759
if ( !layer )
760760
return;
761761

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

917917
// layer id
918-
legendlayerfilenode.setAttribute( "layerid", layer->getLayerID() );
918+
legendlayerfilenode.setAttribute( "layerid", layer->id() );
919919
layerfilegroupnode.appendChild( legendlayerfilenode );
920920

921921
// visible flag
@@ -1022,7 +1022,7 @@ bool QgsLegend::readXML( QgsLegendGroup *parent, const QDomNode &node )
10221022
}
10231023

10241024
// load symbology
1025-
refreshLayerSymbology( currentLayer->layer()->getLayerID() );
1025+
refreshLayerSymbology( currentLayer->layer()->id() );
10261026

10271027
if ( isOpen )
10281028
{
@@ -1101,7 +1101,7 @@ QgsLegendLayer* QgsLegend::findLegendLayer( const QString& layerKey )
11011101
theLegendLayer = dynamic_cast<QgsLegendLayer *>( theItem );
11021102
if ( theLegendLayer ) //item is a legend layer
11031103
{
1104-
if ( theLegendLayer->layer()->getLayerID() == layerKey )
1104+
if ( theLegendLayer->layer()->id() == layerKey )
11051105
{
11061106
return theLegendLayer;
11071107
}
@@ -1221,7 +1221,7 @@ QList< GroupLayerInfo > QgsLegend::groupLayerRelationship()
12211221
if ( lLayer->layer() )
12221222
{
12231223
QList<QString> layerList;
1224-
layerList.push_back( lLayer->layer()->getLayerID() );
1224+
layerList.push_back( lLayer->layer()->id() );
12251225
groupLayerList.push_back( qMakePair( QString(), layerList ) );
12261226
}
12271227
}
@@ -1240,7 +1240,7 @@ QList< GroupLayerInfo > QgsLegend::groupLayerRelationship()
12401240
{
12411241
if ( lLayer->layer() )
12421242
{
1243-
layerList.push_back( lLayer->layer()->getLayerID() );
1243+
layerList.push_back( lLayer->layer()->id() );
12441244
}
12451245
}
12461246

@@ -1449,7 +1449,7 @@ QStringList QgsLegend::layerIDs()
14491449
if ( ll )
14501450
{
14511451
QgsMapLayer *lyr = ll->layer();
1452-
layers.push_front( lyr->getLayerID() );
1452+
layers.push_front( lyr->id() );
14531453
}
14541454
}
14551455

@@ -1729,8 +1729,8 @@ void QgsLegend::legendLayerStretchUsingCurrentExtent()
17291729
}
17301730

17311731
layer->setMinimumMaximumUsingLastExtent();
1732-
layer->setCacheImage(NULL);
1733-
refreshLayerSymbology( layer->getLayerID() );
1732+
layer->setCacheImage( NULL );
1733+
refreshLayerSymbology( layer->id() );
17341734
mMapCanvas->refresh();
17351735
}
17361736
}
@@ -1847,7 +1847,7 @@ void QgsLegend::removeSelectedLayers()
18471847
QgsLegendLayer *ll = dynamic_cast<QgsLegendLayer *>( item );
18481848
if ( ll && ll->layer() )
18491849
{
1850-
QgsMapLayerRegistry::instance()->removeMapLayer( ll->layer()->getLayerID() );
1850+
QgsMapLayerRegistry::instance()->removeMapLayer( ll->layer()->id() );
18511851
continue;
18521852
}
18531853
}

src/app/qgssnappingdialog.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void QgsSnappingDialog::update()
191191
mLayerTreeWidget->setItemWidget( item, 5, cbxAvoidIntersection );
192192
}
193193

194-
int idx = layerIdList.indexOf( currentVectorLayer->getLayerID() );
194+
int idx = layerIdList.indexOf( currentVectorLayer->id() );
195195
if ( idx < 0 )
196196
{
197197
// no settings for this layer yet
@@ -218,7 +218,7 @@ void QgsSnappingDialog::update()
218218
cbxUnits->setCurrentIndex( toleranceUnitList[idx].toInt() );
219219
if ( cbxAvoidIntersection )
220220
{
221-
cbxAvoidIntersection->setChecked( avoidIntersectionsList.contains( currentVectorLayer->getLayerID() ) );
221+
cbxAvoidIntersection->setChecked( avoidIntersectionsList.contains( currentVectorLayer->id() ) );
222222
}
223223
}
224224

src/core/composer/qgscomposerattributetable.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ bool QgsComposerAttributeTable::writeXML( QDomElement& elem, QDomDocument & doc
231231
}
232232
if ( mVectorLayer )
233233
{
234-
composerTableElem.setAttribute( "vectorLayer", mVectorLayer->getLayerID() );
234+
composerTableElem.setAttribute( "vectorLayer", mVectorLayer->id() );
235235
}
236236

237237
//display attributes

src/core/composer/qgslegendmodel.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ int QgsLegendModel::addRasterLayerItem( QStandardItem* layerItem, QgsMapLayer* r
242242
{
243243
currentSymbolItem->setIcon( QIcon( rasterLayer->legendAsPixmap( true ) ) );
244244
}
245-
currentSymbolItem->setLayerID( rasterLayer->getLayerID() );
245+
currentSymbolItem->setLayerID( rasterLayer->id() );
246246
int currentRowCount = layerItem->rowCount();
247247
layerItem->setChild( currentRowCount, 0, currentSymbolItem );
248248

@@ -338,7 +338,7 @@ void QgsLegendModel::addLayer( QgsMapLayer* theMapLayer )
338338
}
339339

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

344344
invisibleRootItem()->setChild( invisibleRootItem()->rowCount(), layerItem );

src/core/qgis.h

+14
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,18 @@ const double DEFAULT_LINE_WIDTH = 0.26;
189189
#endif
190190
#endif
191191

192+
#ifndef QGISDEPRECATED
193+
#ifndef Q_MOC_RUN
194+
#ifdef _MSC_VER
195+
# define QGISDEPRECATED __declspec(deprecated)
196+
#elif __GNUC__
197+
# define QGISDEPRECATED __attribute__((__deprecated__))
198+
#else
199+
# define QGISDEPRECATED
200+
#endif
201+
#else
202+
#define QGISDEPRECATED
203+
#endif
204+
#endif
205+
192206
#endif

src/core/qgsapplication.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include <QApplication>
2020

21+
#include <qgis.h>
22+
2123
/** \ingroup core
2224
* Extends QApplication to provide access to QGIS specific resources such
2325
* as theme paths, database paths etc.
@@ -111,7 +113,7 @@ class CORE_EXPORT QgsApplication: public QApplication
111113

112114
//! Returns the paths to svg applications svg directory.
113115
//! @deprecated since 1.4
114-
static const QString svgPath();
116+
QGISDEPRECATED static const QString svgPath();
115117

116118
//! Returns the path to the application prefix directory.
117119
static const QString prefixPath();

src/core/qgslabel.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ class CORE_EXPORT QgsLabel
103103
* \param rasterScaleFactor raster scale
104104
* \deprecated
105105
*/
106-
void renderLabel( QPainter* painter, const QgsRectangle& viewExtent,
107-
QgsCoordinateTransform* coordinateTransform,
108-
const QgsMapToPixel *transform,
109-
QgsFeature &feature, bool selected, QgsLabelAttributes *classAttributes = 0,
110-
double sizeScale = 1., double rasterScaleFactor = 1.0 )
106+
QGISDEPRECATED void renderLabel( QPainter* painter, const QgsRectangle& viewExtent,
107+
QgsCoordinateTransform* coordinateTransform,
108+
const QgsMapToPixel *transform,
109+
QgsFeature &feature, bool selected, QgsLabelAttributes *classAttributes = 0,
110+
double sizeScale = 1., double rasterScaleFactor = 1.0 )
111111
{
112112
QgsRenderContext r;
113113
r.setExtent( viewExtent );
@@ -148,7 +148,7 @@ class CORE_EXPORT QgsLabel
148148
/** Pointer to default attributes.
149149
* @deprecated in version 2 as it is badly named. Rather use attributes.
150150
* @see labelAttributes method rather */
151-
QgsLabelAttributes *layerAttributes( void );
151+
QGISDEPRECATED QgsLabelAttributes *layerAttributes( void );
152152

153153
/** Pointer to default attributes.
154154
* @note this replaces the to-be-deprecated layerAttributes method.

src/core/qgsmaplayer.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <QVariant>
2626
#include <QImage>
2727

28+
#include "qgis.h"
2829
#include "qgsrectangle.h"
2930

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

8081
/** Set the display name of the layer
8182
* @param name New name for the layer

src/core/qgsmaprenderer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject
135135

136136
//! Return the measuring object
137137
//! @deprecated
138-
QgsDistanceArea* distanceArea() { return mDistArea; }
138+
QGISDEPRECATED QgsDistanceArea *distanceArea() { return mDistArea; }
139139
QGis::UnitType mapUnits() const;
140140
void setMapUnits( QGis::UnitType u );
141141

src/core/qgsoverlayobject.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ class CORE_EXPORT QgsOverlayObject
4343
/**Returns the feature geometry in geos format. The calling function does _not_ take
4444
ownership of the generated object. The geometry is in map coordinates
4545
@deprecated Please use geometry() and QgsGeometry::asGeos instead*/
46-
GEOSGeometry* getGeosGeometry();
46+
QGISDEPRECATED GEOSGeometry* getGeosGeometry();
4747
/**Feature geometry is released when object is destructed so this function is empty.
4848
* @deprecated nop
4949
*/
50-
void releaseGeosGeometry( GEOSGeometry *the_geom ) { Q_UNUSED( the_geom ); }
50+
QGISDEPRECATED void releaseGeosGeometry( GEOSGeometry *the_geom ) { Q_UNUSED( the_geom ); }
5151

5252
//getters
5353
int width() const {return mWidth;}

0 commit comments

Comments
 (0)