Skip to content

Commit cf0ed8d

Browse files
author
jef
committed
fix internal use of deprecated methods and fix related warnings
git-svn-id: http://svn.osgeo.org/qgis/trunk@15210 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent ce8e3d5 commit cf0ed8d

File tree

11 files changed

+51
-41
lines changed

11 files changed

+51
-41
lines changed

src/analysis/raster/qgsrastercalcparser.yy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
%{
2020
#include "qgsrastercalcnode.h"
2121

22+
#ifdef _MSC_VER
23+
# pragma warnings( disable: 4065 ) // switch statement contains 'default' but no 'case' labels
24+
# pragma warnings( disable: 4701 ) // Potentially uninitialized local variable 'name' used
25+
#endif
26+
2227
// don't redeclare malloc/free
2328
#define YYINCLUDED_STDLIB_H 1
2429

src/app/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,9 @@ ENDIF (WIN32)
349349

350350
IF(PEDANTIC)
351351
# disable deprecation warnings
352-
IF(MSVC)
353-
SET_SOURCE_FILES_PROPERTIES(qgisappinterface.cpp PROPERTIES COMPILE_FLAGS /wd4996)
354-
ELSE(MSVC)
352+
IF(NOT MSVC)
355353
SET_SOURCE_FILES_PROPERTIES(qgisappinterface.cpp PROPERTIES COMPILE_FLAGS -Wno-deprecated)
356-
ENDIF(MSVC)
354+
ENDIF(NOT MSVC)
357355
ENDIF(PEDANTIC)
358356

359357
INCLUDE_DIRECTORIES(

src/app/gps/qwtpolar/qwt_polar_itemdict.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ class QwtPolarItemDict::PrivateData
2828
// for lists in Qt4. The implementation below
2929
// is slow, but there shouldn't be many plot items.
3030

31-
#ifdef __GNUC__
32-
#warning binary search missing
33-
#endif
31+
// TODO add binary search
3432

3533
#if QT_VERSION < 0x040000
3634
QValueListIterator<QwtPolarItem *> it;

src/app/qgisappinterface.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424

2525
class QgisApp;
2626

27+
#ifdef _MSC_VER
28+
# pragma warning( push )
29+
# pragma warning( disable: 4996 ) // declared deprecated
30+
#endif
31+
2732
/** \class QgisAppInterface
2833
* \brief Interface class to provide access to private methods in QgisApp
2934
* for use by plugins.
@@ -304,5 +309,8 @@ class QgisAppInterface : public QgisInterface
304309
QgsAppLegendInterface legendIface;
305310
};
306311

312+
#ifdef _MSC_VER
313+
# pragma warning( pop )
314+
#endif
307315

308316
#endif //#define QGISAPPINTERFACE_H

src/core/CMakeLists.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -212,20 +212,6 @@ ADD_FLEX_FILES(QGIS_CORE_SRCS qgssearchstringlexer.ll)
212212

213213
ADD_BISON_FILES(QGIS_CORE_SRCS qgssearchstringparser.yy)
214214

215-
# Disable compiler warnings for lex generated sources
216-
SET_SOURCE_FILES_PROPERTIES(
217-
${CMAKE_BINARY_DIR}/src/core/flex_qgssearchstringlexer.cpp
218-
PROPERTIES COMPILE_FLAGS -w)
219-
220-
IF (MSVC AND PEDANTIC)
221-
# disable warnings
222-
# 4065 switch with default and no case
223-
# 4702 unreachable code
224-
SET_SOURCE_FILES_PROPERTIES(
225-
${CMAKE_BINARY_DIR}/src/core/qgssearchstringparser.cpp
226-
PROPERTIES COMPILE_FLAGS "-wd4065 -wd4702")
227-
ENDIF (MSVC AND PEDANTIC)
228-
229215
SET(QGIS_CORE_MOC_HDRS
230216
qgsapplication.h
231217
qgscontexthelp.h

src/core/qgssearchstringlexer.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
%option noyywrap
2121
%option case-insensitive
2222
%option never-interactive
23+
%option nounput
2324

2425
// ensure that lexer will be 8-bit (and not just 7-bit)
2526
%option 8bit
@@ -35,6 +36,8 @@
3536
// which doesn't in MSVC compiler
3637
#define YY_NEVER_INTERACTIVE 1
3738

39+
#define YY_NO_UNPUT // unused
40+
3841
#ifdef _MSC_VER
3942
#define YY_NO_UNISTD_H
4043
#endif

src/core/qgssearchstringparser.yy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
#include <cstdlib>
2424
#include "qgssearchtreenode.h"
2525

26+
#ifdef _MSC_VER
27+
# pragma warning( disable: 4065 ) // switch statement contains 'default' but no 'case' labels
28+
# pragma warning( disable: 4702 ) // unreachable code
29+
#endif
30+
2631
// don't redeclare malloc/free
2732
#define YYINCLUDED_STDLIB_H 1
2833

src/gui/CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ qgssearchquerybuilder.h
104104

105105
QT4_WRAP_CPP(QGIS_GUI_MOC_SRCS ${QGIS_GUI_MOC_HDRS})
106106

107-
IF(MSVC AND PEDANTIC)
108-
# disable deprecation warnings for qgisinterface (re-exporting deprecated methods)
109-
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/src/gui/moc_qgisinterface.cxx PROPERTIES COMPILE_FLAGS "-wd4996")
110-
ENDIF(MSVC AND PEDANTIC)
111107

112108
INCLUDE_DIRECTORIES(
113109
${QT_QTUITOOLS_INCLUDE_DIR}
@@ -139,11 +135,14 @@ IF (WIN32)
139135
ENDIF (MSVC)
140136
ENDIF (WIN32)
141137

138+
IF(NOT MSVC)
139+
# disable deprecation warnings for qgisinterface (re-exporting deprecated methods)
140+
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/src/gui/moc_qgisinterface.cxx PROPERTIES COMPILE_FLAGS "-w")
141+
ENDIF(NOT MSVC)
142142

143143
#############################################################
144144
# qgis_gui library
145145

146-
147146
ADD_LIBRARY(qgis_gui SHARED ${QGIS_GUI_SRCS} ${QGIS_GUI_MOC_SRCS})
148147

149148
SET_TARGET_PROPERTIES(qgis_gui PROPERTIES VERSION ${COMPLETE_VERSION} SOVERSION ${COMPLETE_VERSION})

src/gui/qgisinterface.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ class QgsFeature;
4040

4141
#include <qgis.h>
4242

43+
#ifdef _MSC_VER
44+
# pragma warning( push )
45+
# pragma warning( disable: 4996 ) // was declared deprecated
46+
#endif
4347

4448
/** \ingroup gui
4549
* QgisInterface
@@ -367,14 +371,15 @@ class GUI_EXPORT QgisInterface : public QObject
367371

368372
};
369373

374+
#ifdef _MSC_VER
375+
# pragma warning( pop )
376+
# pragma warning( disable: 4190 )
377+
#endif
378+
370379
// FIXME: also in core/qgis.h
371380
#ifndef QGISEXTERN
372381
#ifdef WIN32
373382
# define QGISEXTERN extern "C" __declspec( dllexport )
374-
# ifdef _MSC_VER
375-
// do not warn about C bindings returning QString
376-
# pragma warning(disable:4190)
377-
# endif
378383
#else
379384
# define QGISEXTERN extern "C"
380385
#endif

src/plugins/diagram_overlay/qgssvgdiagramfactorywidget.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,19 +217,22 @@ int QgsSVGDiagramFactoryWidget::addDirectoryToPreview( const QString& path )
217217
void QgsSVGDiagramFactoryWidget::addStandardDirectoriesToPreview()
218218
{
219219
//list all directories in $prefix/share/qgis/svg
220-
QDir svgDirectory( QgsApplication::svgPath() );
221-
if ( !svgDirectory.exists() || !svgDirectory.isReadable() )
220+
foreach( QString path, QgsApplication::svgPaths() )
222221
{
223-
return; //error
224-
}
222+
QDir svgDirectory( path );
223+
if ( !svgDirectory.exists() || !svgDirectory.isReadable() )
224+
{
225+
continue; //error
226+
}
225227

226-
QFileInfoList directoryList = svgDirectory.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
227-
QFileInfoList::const_iterator dirIt = directoryList.constBegin();
228-
for ( ; dirIt != directoryList.constEnd(); ++dirIt )
229-
{
230-
if ( addDirectoryToPreview( dirIt->absoluteFilePath() ) == 0 )
228+
QFileInfoList directoryList = svgDirectory.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
229+
QFileInfoList::const_iterator dirIt = directoryList.constBegin();
230+
for ( ; dirIt != directoryList.constEnd(); ++dirIt )
231231
{
232-
mSearchDirectoriesComboBox->addItem( dirIt->absoluteFilePath() );
232+
if ( addDirectoryToPreview( dirIt->absoluteFilePath() ) == 0 )
233+
{
234+
mSearchDirectoriesComboBox->addItem( dirIt->absoluteFilePath() );
235+
}
233236
}
234237
}
235238
}

src/providers/osm/osmstyle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void OsmStyle::parse_rule_point( QString line )
139139
QColor mSelectionColor( 255, 255, 0 );
140140

141141
QgsSymbol sym( QGis::Point );
142-
sym.setNamedPointSymbol( QString( "svg:%1%2" ).arg( QgsApplication::svgPath() ).arg( name ) );
142+
sym.setNamedPointSymbol( QString( "svg:%1" ).arg( name ) );
143143
sym.setPointSize( size.toFloat() );
144144

145145
QImage img = sym.getPointSymbolAsImage( widthScale, selected, mSelectionColor );

0 commit comments

Comments
 (0)