Skip to content

Commit

Permalink
various code cleanups by mloskot for GCC 4.1 (fixes #1239, #1240).
Browse files Browse the repository at this point in the history
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 2e5506a
Show file tree
Hide file tree
Showing 107 changed files with 333 additions and 377 deletions.
16 changes: 15 additions & 1 deletion CMakeLists.txt
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/app/legend/qgslegend.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/legend/qgslegendlayerfile.h
Expand Up @@ -32,7 +32,7 @@ class QgsMapLayer;
*/
class QgsLegendLayerFile : public QgsLegendItem
{
Q_OBJECT;
Q_OBJECT

public:
QgsLegendLayerFile(QTreeWidgetItem * theLegendItem, QString theString, QgsMapLayer* theLayer);
Expand Down
5 changes: 3 additions & 2 deletions src/app/main.cpp
Expand Up @@ -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?

Expand All @@ -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);
Expand Down
23 changes: 12 additions & 11 deletions src/app/qgisapp.cpp
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2451,7 +2452,7 @@ findLayer_( QString const & fileFilters, QDomNode const & constLayerNode )
break;
}

}; // findLayer_
} // findLayer_



Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.h
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappinterface.h
Expand Up @@ -32,7 +32,7 @@ class QgisApp;
*/
class QgisAppInterface : public QgisInterface
{
Q_OBJECT;
Q_OBJECT

public:
/**
Expand Down
3 changes: 1 addition & 2 deletions src/app/qgsabout.cpp
Expand Up @@ -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]);
*/
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributeactiondialog.cpp
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributeactiondialog.h
Expand Up @@ -32,7 +32,7 @@ class QgsAttributeAction;

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

public:
QgsAttributeActionDialog(QgsAttributeAction* actions,
Expand Down
110 changes: 55 additions & 55 deletions src/app/qgsattributedialog.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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() );

Expand All @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributedialog.h
Expand Up @@ -31,7 +31,7 @@ class QgsVectorLayer;

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

public:
QgsAttributeDialog(QgsVectorLayer *vl, QgsFeature * thepFeature);
Expand Down
4 changes: 1 addition & 3 deletions src/app/qgsattributetable.cpp
Expand Up @@ -33,7 +33,7 @@


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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributetable.h
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsdbsourceselect.h
Expand Up @@ -103,7 +103,7 @@ class QgsDbSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
dbssType=0,
dbssDetail,
dbssSql,
dbssColumns,
dbssColumns
};

typedef std::pair<QString, QString> geomPair;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsdbtablemodel.h
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsidentifyresults.h
Expand Up @@ -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
Expand Down

0 comments on commit 2e5506a

Please sign in to comment.