Skip to content
Permalink
Browse files
various code cleanups by mloskot for GCC 4.1 (fixes #1239, #1240).
Inspired by it I also enabled pedantic mode for MSVC and cleaned
up some more warnings found by GCC 4.3 and MSVC.




git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9133 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Aug 23, 2008
1 parent 7703910 commit 2e5506a267892d8897b8e9fda20263098bc0fc90
Showing with 333 additions and 377 deletions.
  1. +15 −1 CMakeLists.txt
  2. +1 −1 src/app/legend/qgslegend.h
  3. +1 −1 src/app/legend/qgslegendlayerfile.h
  4. +3 −2 src/app/main.cpp
  5. +12 −11 src/app/qgisapp.cpp
  6. +1 −1 src/app/qgisapp.h
  7. +1 −1 src/app/qgisappinterface.h
  8. +1 −2 src/app/qgsabout.cpp
  9. +1 −1 src/app/qgsattributeactiondialog.cpp
  10. +1 −1 src/app/qgsattributeactiondialog.h
  11. +55 −55 src/app/qgsattributedialog.cpp
  12. +1 −1 src/app/qgsattributedialog.h
  13. +1 −3 src/app/qgsattributetable.cpp
  14. +1 −1 src/app/qgsattributetable.h
  15. +1 −1 src/app/qgsdbsourceselect.h
  16. +1 −1 src/app/qgsdbtablemodel.h
  17. +1 −1 src/app/qgsidentifyresults.h
  18. +1 −1 src/app/qgslabeldialog.h
  19. +0 −1 src/app/qgsmaptooledit.cpp
  20. +1 −1 src/app/qgsmaptoolidentify.h
  21. +1 −1 src/app/qgsmaptoolsplitfeatures.h
  22. +1 −1 src/app/qgsmaptoolvertexedit.h
  23. +5 −6 src/app/qgsmeasuredialog.cpp
  24. +1 −1 src/app/qgsmeasuredialog.h
  25. +1 −1 src/app/qgsmeasuretool.h
  26. +1 −1 src/app/qgsoptions.h
  27. +1 −1 src/app/qgspastetransformations.h
  28. +4 −3 src/app/qgspluginmanager.cpp
  29. +4 −4 src/app/qgsrasterlayerproperties.cpp
  30. +1 −1 src/app/qgssearchquerybuilder.cpp
  31. +2 −2 src/app/qgssearchquerybuilder.h
  32. +0 −33 src/app/qgsserversourceselect.cpp
  33. +0 −3 src/app/qgsserversourceselect.h
  34. +1 −1 src/app/qgsvectorlayerproperties.h
  35. +9 −0 src/core/CMakeLists.txt
  36. +3 −1 src/core/composer/qgscomposerlegend.cpp
  37. +1 −1 src/core/composer/qgscomposerpicture.cpp
  38. +4 −0 src/core/composer/qgscomposition.cpp
  39. +5 −2 src/core/composer/qgslegendmodel.cpp
  40. +1 −1 src/core/composer/qgsscalebarstyle.cpp
  41. +1 −0 src/core/composer/qgsticksscalebarstyle.cpp
  42. +16 −0 src/core/qgis.h
  43. +1 −1 src/core/qgsclipper.h
  44. +3 −3 src/core/qgsfeature.cpp
  45. +1 −1 src/core/qgsfeature.h
  46. +20 −22 src/core/qgsgeometry.cpp
  47. +1 −1 src/core/qgsgeometry.h
  48. +13 −12 src/core/qgslabel.cpp
  49. +1 −2 src/core/qgsmaprenderer.cpp
  50. +0 −11 src/core/qgsproject.cpp
  51. +5 −4 src/core/qgsprojectfiletransform.cpp
  52. +1 −1 src/core/qgsprojectfiletransform.h
  53. +3 −3 src/core/qgsprojectversion.cpp
  54. +7 −7 src/core/qgsproviderregistry.cpp
  55. +3 −0 src/core/qgssearchstringparser.yy
  56. +0 −2 src/core/qgssearchtreenode.cpp
  57. +2 −1 src/core/qgsvectorfilewriter.cpp
  58. +5 −7 src/core/qgsvectorlayer.cpp
  59. +1 −1 src/core/qgsvectorlayer.h
  60. +8 −0 src/core/raster/qgscontrastenhancement.cpp
  61. +0 −1 src/core/raster/qgscontrastenhancementfunction.cpp
  62. +8 −6 src/core/raster/qgsrasterlayer.cpp
  63. +0 −15 src/core/spatialindex/geometry/LineSegment.cc
  64. +10 −23 src/core/spatialindex/tools/Tools.cc
  65. +0 −2 src/core/symbology/qgsmarkercatalogue.cpp
  66. +1 −1 src/gui/qgisinterface.h
  67. +0 −1 src/gui/qgsdetaileditemdelegate.cpp
  68. +1 −1 src/gui/qgsdetaileditemdelegate.h
  69. +1 −1 src/gui/qgsdetaileditemwidget.h
  70. +3 −3 src/gui/qgsfiledropedit.cpp
  71. +1 −1 src/gui/qgsgenericprojectionselector.h
  72. +1 −1 src/gui/qgsmapcanvas.h
  73. +1 −1 src/gui/qgsmapoverviewcanvas.h
  74. +1 −6 src/gui/qgsquickprint.cpp
  75. +1 −1 src/gui/qgsquickprint.h
  76. +1 −1 src/plugins/coordinate_capture/coordinatecapture.h
  77. +1 −1 src/plugins/coordinate_capture/coordinatecapturemaptool.h
  78. +1 −1 src/plugins/copyright_label/plugingui.h
  79. +0 −14 src/plugins/grass/CMakeLists.txt
  80. +1 −1 src/plugins/grass/qgsgrassattributes.cpp
  81. +2 −2 src/plugins/grass/qgsgrassattributes.h
  82. +1 −1 src/plugins/grass/qgsgrassbrowser.h
  83. +1 −1 src/plugins/grass/qgsgrassedit.h
  84. +1 −1 src/plugins/grass/qgsgrassmodel.h
  85. +13 −14 src/plugins/grass/qgsgrassmodule.cpp
  86. +8 −8 src/plugins/grass/qgsgrassmodule.h
  87. +1 −1 src/plugins/grass/qgsgrassnewmapset.cpp
  88. +1 −1 src/plugins/grass/qgsgrassnewmapset.h
  89. +1 −1 src/plugins/grass/qgsgrassregion.h
  90. +2 −3 src/plugins/grass/qgsgrassselect.cpp
  91. +1 −1 src/plugins/grass/qgsgrassselect.h
  92. +2 −2 src/plugins/grass/qgsgrassshell.h
  93. +1 −1 src/plugins/grass/qgsgrasstools.h
  94. +1 −1 src/plugins/grass/qgsgrassutils.h
  95. +1 −1 src/plugins/plugin_template/plugin.h
  96. +2 −2 src/plugins/quick_print/quickprintgui.cpp
  97. +1 −1 src/plugins/quick_print/quickprintplugin.h
  98. +1 −1 src/plugins/scale_bar/plugingui.h
  99. +2 −2 src/plugins/spit/qgsspit.h
  100. +1 −1 src/providers/delimitedtext/qgsdelimitedtextprovider.h
  101. +2 −2 src/providers/memory/memoryprovider.cpp
  102. +4 −5 src/providers/ogr/qgsogrprovider.cpp
  103. +2 −2 src/providers/postgres/qgspostgresprovider.cpp
  104. +1 −1 src/providers/postgres/qgspostgresprovider.h
  105. +6 −6 src/providers/wfs/CMakeLists.txt
  106. +2 −1 src/providers/wfs/qgswfsprovider.cpp
  107. +1 −1 tests/src/core/qgsrenderchecker.cpp
@@ -167,7 +167,21 @@ FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
# enable warnings

IF (PEDANTIC)
ADD_DEFINITIONS( -Wall -Werror )
MESSAGE ("Pedantic compiler settings enabled")
IF(MSVC)
ADD_DEFINITIONS( /W4 )

# disable warnings
ADD_DEFINITIONS( /wd4100 ) # unused formal parameters
ADD_DEFINITIONS( /wd4127 ) # constant conditional expressions (used in Qt template classes)
ADD_DEFINITIONS( /wd4510 ) # default constructor could not be generated (sqlite3_index_info, QMap)
ADD_DEFINITIONS( /wd4512 ) # assignment operator could not be generated (sqlite3_index_info)
ADD_DEFINITIONS( /wd4610 ) # user defined constructor required (sqlite3_index_info)
ELSE (MSVC)
ADD_DEFINITIONS( -Wall -Werror -Wno-long-long )
# Qt produces lots of warnings with strict aliasing (as of Qt 4.4.0 & GCC 4.3)
# ADD_DEFINITIONS( -fstrict-aliasing -Wstrict-aliasing=1 )
ENDIF (MSVC)
ENDIF (PEDANTIC)

IF (CMAKE_BUILD_TYPE MATCHES Debug)
@@ -82,7 +82,7 @@ class QTreeWidgetItem;

class QgsLegend : public QTreeWidget
{
Q_OBJECT;
Q_OBJECT
private:
// Moved here to match access of declaration later in file.
// Previous location raised a warning in msvc as the forward
@@ -32,7 +32,7 @@ class QgsMapLayer;
*/
class QgsLegendLayerFile : public QgsLegendItem
{
Q_OBJECT;
Q_OBJECT

public:
QgsLegendLayerFile(QTreeWidgetItem * theLegendItem, QString theString, QgsMapLayer* theLayer);
@@ -612,7 +612,7 @@ int main(int argc, char *argv[])
{
double coords[4];
int pos, posOld = 0;
bool ok;
bool ok = true;

// XXX is it necessary to switch to "C" locale?

@@ -623,7 +623,8 @@ int main(int argc, char *argv[])
// find comma and get coordinate
pos = myInitialExtent.indexOf(',', posOld);
if (pos == -1) {
ok = false; break;
ok = false;
break;
}

coords[i] = QString( myInitialExtent.mid(posOld, pos - posOld) ).toDouble(&ok);
@@ -314,7 +314,8 @@ QgisApp *QgisApp::smInstance = 0;
QgisApp::QgisApp(QSplashScreen *splash, QWidget * parent, Qt::WFlags fl)
: QMainWindow(parent,fl),
mSplash(splash),
mPythonUtils(NULL), mPythonConsole(NULL)
mPythonConsole(NULL),
mPythonUtils(NULL)
{
if(smInstance) {
QMessageBox::critical(
@@ -1662,9 +1663,9 @@ void QgisApp::restoreSessionPlugins(QString thePluginDirString)
if (loaded)
{

name_t * myName =(name_t *) myLib->resolve("name");
description_t * myDescription = (description_t *) myLib->resolve("description");
version_t * myVersion = (version_t *) myLib->resolve("version");
name_t * myName =(name_t *) cast_to_fptr(myLib->resolve("name"));
description_t * myDescription = (description_t *) cast_to_fptr(myLib->resolve("description"));
version_t * myVersion = (version_t *) cast_to_fptr(myLib->resolve("version"));
if (myName && myDescription && myVersion )
{
//check if the plugin was active on last session
@@ -2451,7 +2452,7 @@ findLayer_( QString const & fileFilters, QDomNode const & constLayerNode )
break;
}

}; // findLayer_
} // findLayer_



@@ -2661,7 +2662,7 @@ void QgisApp::newVectorLayer()

typedef bool (*createEmptyDataSourceProc)(const QString&, const QString&, const QString&, QGis::WKBTYPE, \
const std::list<std::pair<QString, QString> >&);
createEmptyDataSourceProc createEmptyDataSource=(createEmptyDataSourceProc)myLib->resolve("createEmptyDataSource");
createEmptyDataSourceProc createEmptyDataSource=(createEmptyDataSourceProc) cast_to_fptr(myLib->resolve("createEmptyDataSource"));
if(createEmptyDataSource)
{
#if 0
@@ -3926,7 +3927,7 @@ void QgisApp::loadPythonSupport()
{
//QgsDebugMsg("Python support library loaded successfully.");
typedef QgsPythonUtils* (*inst)();
inst pythonlib_inst = (inst) pythonlib.resolve("instance");
inst pythonlib_inst = (inst) cast_to_fptr(pythonlib.resolve("instance"));
if (pythonlib_inst)
{
//QgsDebugMsg("Python support library's instance() symbol resolved.");
@@ -4009,15 +4010,15 @@ void QgisApp::loadPlugin(QString name, QString description, QString theFullPathN
{
myError += "Attempting to resolve the classFactory function " + QString (__LINE__) + " in " + QString (__FUNCTION__ ) + "\n";

type_t *pType = (type_t *) myLib->resolve("type");
type_t *pType = (type_t *) cast_to_fptr(myLib->resolve("type"));

switch (pType())
{
case QgisPlugin::RENDERER:
case QgisPlugin::UI:
{
// UI only -- doesn't use mapcanvas
create_ui *cf = (create_ui *) myLib->resolve("classFactory");
create_ui *cf = (create_ui *) cast_to_fptr(myLib->resolve("classFactory"));
if (cf)
{
QgisPlugin *pl = cf(mQgisInterface);
@@ -4049,7 +4050,7 @@ void QgisApp::loadPlugin(QString name, QString description, QString theFullPathN
case QgisPlugin::MAPLAYER:
{
// Map layer - requires interaction with the canvas
create_it *cf = (create_it *) myLib->resolve("classFactory");
create_it *cf = (create_it *) cast_to_fptr(myLib->resolve("classFactory"));
if (cf)
{
QgsMapLayerInterface *pl = cf();
@@ -4412,7 +4413,7 @@ bool QgisApp::saveDirty()
QSettings settings;
bool askThem = settings.value("qgis/askToSaveProjectChanges", true).toBool();

if (askThem && (QgsProject::instance()->isDirty() || (mMapCanvas->isDirty()) && mMapCanvas->layerCount() > 0))
if (askThem && (QgsProject::instance()->isDirty() || mMapCanvas->isDirty()) && mMapCanvas->layerCount() > 0)
{
// flag project as dirty since dirty state of canvas is reset if "dirty"
// is based on a zoom or pan
@@ -68,7 +68,7 @@ class QgsVectorLayer;
*/
class QgisApp : public QMainWindow
{
Q_OBJECT;
Q_OBJECT
public:
//! Constructor
QgisApp(QSplashScreen *splash, QWidget * parent = 0, Qt::WFlags fl = Qt::Window);
@@ -32,7 +32,7 @@ class QgisApp;
*/
class QgisAppInterface : public QgisInterface
{
Q_OBJECT;
Q_OBJECT

public:
/**
@@ -215,8 +215,7 @@ void QgsAbout::on_listBox1_currentItemChanged(QListWidgetItem *theItem)
#ifdef QGISDEBUG
printf ("Loading mug: %s\n", myString.toLocal8Bit().constData());
#endif
QPixmap *pixmap = new QPixmap(myString);
//pixAuthorMug->setPixmap(*pixmap);

/* Uncomment this block to use preloaded images
pixAuthorMug->setPixmap(mugs[myString]);
*/
@@ -82,7 +82,7 @@ void QgsAttributeActionDialog::insertRow(int row, const QString &name, const QSt
attributeActionTable->setItem(row, 0, new QTableWidgetItem(name));
attributeActionTable->setItem(row, 1, new QTableWidgetItem(action));
QTableWidgetItem* item = new QTableWidgetItem();
item->setFlags(item->flags() & ~Qt::ItemIsEditable | Qt::ItemIsUserCheckable);
item->setFlags(item->flags() & ~(Qt::ItemIsEditable | Qt::ItemIsUserCheckable) );
item->setCheckState(capture ? Qt::Checked : Qt::Unchecked);
attributeActionTable->setItem(row, 2, item);
}
@@ -32,7 +32,7 @@ class QgsAttributeAction;

class QgsAttributeActionDialog: public QWidget, private Ui::QgsAttributeActionDialogBase
{
Q_OBJECT;
Q_OBJECT

public:
QgsAttributeActionDialog(QgsAttributeAction* actions,
@@ -38,8 +38,8 @@
QgsAttributeDialog::QgsAttributeDialog(QgsVectorLayer *vl, QgsFeature *thepFeature)
: QDialog(),
mSettingsPath("/Windows/AttributeDialog/"),
mpFeature(thepFeature),
mLayer(vl)
mLayer(vl),
mpFeature(thepFeature)
{
setupUi(this);
if (mpFeature==NULL || vl->dataProvider()==NULL )
@@ -109,6 +109,58 @@ QgsAttributeDialog::QgsAttributeDialog(QgsVectorLayer *vl, QgsFeature *thepFeatu

switch( editType )
{
case QgsVectorLayer::UniqueValues:
{
QStringList values;
mLayer->dataProvider()->getUniqueValues(it.key(), values);

QComboBox *cb = new QComboBox();
cb->setEditable(true);
cb->addItems(values);

int idx = cb->findText( myFieldValue.toString() );
if( idx>= 0 )
cb->setCurrentIndex( idx );

myWidget = cb;
}
break;

case QgsVectorLayer::ValueMap:
{
const QMap<QString,QVariant> &map = vl->valueMap( it.key() );

QComboBox *cb = new QComboBox();

for(QMap<QString,QVariant>::const_iterator it=map.begin(); it!=map.end(); it++)
{
cb->addItem( it.key(), it.value() );
}

int idx = cb->findData( myFieldValue );
if( idx>= 0 )
cb->setCurrentIndex( idx );

myWidget = cb;
}
break;

case QgsVectorLayer::Classification:
{
QComboBox *cb = new QComboBox();
for(QMap<QString,QString>::const_iterator it=classes.begin(); it!=classes.end(); it++)
{
cb->addItem( it.value(), it.key() );
}

int idx = cb->findData( myFieldValue );
if( idx>=0 )
cb->setCurrentIndex( idx );

myWidget = cb;
}
break;

case QgsVectorLayer::Range:
{
if( myFieldType==QVariant::Int )
@@ -145,9 +197,9 @@ QgsAttributeDialog::QgsAttributeDialog(QgsVectorLayer *vl, QgsFeature *thepFeatu

// fall-through


case QgsVectorLayer::LineEdit:
case QgsVectorLayer::UniqueValuesEditable:
default:
{
QLineEdit *le = new QLineEdit( myFieldValue.toString() );

@@ -173,58 +225,6 @@ QgsAttributeDialog::QgsAttributeDialog(QgsVectorLayer *vl, QgsFeature *thepFeatu
myWidget = le;
}
break;

case QgsVectorLayer::UniqueValues:
{
QStringList values;
mLayer->dataProvider()->getUniqueValues(it.key(), values);

QComboBox *cb = new QComboBox();
cb->setEditable(true);
cb->addItems(values);

int idx = cb->findText( myFieldValue.toString() );
if( idx>= 0 )
cb->setCurrentIndex( idx );

myWidget = cb;
}
break;

case QgsVectorLayer::ValueMap:
{
const QMap<QString,QVariant> &map = vl->valueMap( it.key() );

QComboBox *cb = new QComboBox();

for(QMap<QString,QVariant>::const_iterator it=map.begin(); it!=map.end(); it++)
{
cb->addItem( it.key(), it.value() );
}

int idx = cb->findData( myFieldValue );
if( idx>= 0 )
cb->setCurrentIndex( idx );

myWidget = cb;
}
break;

case QgsVectorLayer::Classification:
{
QComboBox *cb = new QComboBox();
for(QMap<QString,QString>::const_iterator it=classes.begin(); it!=classes.end(); it++)
{
cb->addItem( it.value(), it.key() );
}

int idx = cb->findData( myFieldValue );
if( idx>=0 )
cb->setCurrentIndex( idx );

myWidget = cb;
}
break;
}

if( myFieldType==QVariant::Int )
@@ -31,7 +31,7 @@ class QgsVectorLayer;

class QgsAttributeDialog: public QDialog, private Ui::QgsAttributeDialogBase
{
Q_OBJECT;
Q_OBJECT

public:
QgsAttributeDialog(QgsVectorLayer *vl, QgsFeature * thepFeature);
@@ -33,7 +33,7 @@


QgsAttributeTableItemDelegate::QgsAttributeTableItemDelegate(QgsAttributeTable *table, QObject *parent)
: mTable(table), QItemDelegate(parent)
: QItemDelegate(parent), mTable(table)
{
}

@@ -429,8 +429,6 @@ void QgsAttributeTable::copySelectedRows()

void QgsAttributeTable::fillTable(QgsVectorLayer *layer)
{
int row = 0;

const QgsFieldMap &fields = layer->pendingFields();

// set up the column headers
@@ -57,7 +57,7 @@ class QgsAttributeTable : public QTableWidget
enum {
AttributeIndex = Qt::UserRole,
AttributeName = Qt::UserRole+1,
AttributeType = Qt::UserRole+2,
AttributeType = Qt::UserRole+2
};

void setReadOnly(bool b);
@@ -103,7 +103,7 @@ class QgsDbSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
dbssType=0,
dbssDetail,
dbssSql,
dbssColumns,
dbssColumns
};

typedef std::pair<QString, QString> geomPair;
@@ -24,7 +24,7 @@ schemas are the root elements that contain the individual tables as children.
The tables have the following columns: Type, Schema, Tablename, Geometry Column, Sql*/
class QgsDbTableModel: public QStandardItemModel
{
Q_OBJECT;
Q_OBJECT
public:
QgsDbTableModel();
~QgsDbTableModel();
@@ -36,7 +36,7 @@ class QMenu;

class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
{
Q_OBJECT;
Q_OBJECT
public:

//! Constructor - takes it own copy of the QgsAttributeAction so

0 comments on commit 2e5506a

Please sign in to comment.