Fixed compiler warnings:

- for potentially unintialised vars I set them all to 0, NULL or some similar default
 - grass has some warnings for multiple definitions of NDEBUG - Ive disabled warnings on 
   all files relying on grass headers - and submitted a bug to grass.


git-svn-id: http://svn.osgeo.org/qgis/trunk@7059 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2007-07-04 15:43:44 +00:00
parent bbe9992ef0
commit 451230ed5c
22 changed files with 108 additions and 72 deletions

View File

@ -362,7 +362,7 @@ void QgsComposer::on_mActionPrint_activated(void)
try {
std::cout << "Print to file" << std::endl;
QPrinter::PageSize psize;
QPrinter::PageSize psize (QPrinter::A4); //default to A4
// WARNING mPrinter->outputFormat() returns always 0 in Qt 4.2.2
// => we have to check extension

View File

@ -383,7 +383,7 @@ void QgsComposerMap::on_mCalculateComboBox_activated( int )
double QgsComposerMap::scaleFromUserScale ( double us )
{
double s;
double s=0;
switch ( mComposition->mapCanvas()->mapUnits() ) {
case QGis::METERS :
@ -402,7 +402,7 @@ double QgsComposerMap::scaleFromUserScale ( double us )
double QgsComposerMap::userScaleFromScale ( double s )
{
double us;
double us=0;
switch ( mComposition->mapCanvas()->mapUnits() ) {
case QGis::METERS :

View File

@ -156,8 +156,8 @@ QRect QgsComposerScalebar::render ( QPainter *p )
std::cout << "QgsComposerScalebar::render p = " << p << std::endl;
// Painter can be 0, create dummy to avoid many if below
QPainter *painter;
QPixmap *pixmap;
QPainter *painter = NULL;
QPixmap *pixmap = NULL;
if ( p ) {
painter = p;
} else {
@ -191,8 +191,8 @@ QRect QgsComposerScalebar::render ( QPainter *p )
// Not sure about Style Strategy, QFont::PreferMatch?
font.setStyleStrategy ( (QFont::StyleStrategy) (QFont::PreferOutline | QFont::PreferAntialias) );
int xmin; // min x
int xmax; // max x
int xmin = 0; // min x
int xmax = 0; // max x
int ymin; // min y
int ymax; // max y

View File

@ -148,8 +148,8 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
std::cout << "QgsComposerVectorLegend::render p = " << p << std::endl;
// Painter can be 0, create dummy to avoid many if below
QPainter *painter;
QPixmap *pixmap;
QPainter *painter = NULL;
QPixmap *pixmap = NULL;
if ( p ) {
painter = p;
} else {
@ -753,7 +753,7 @@ void QgsComposerVectorLegend::groupLayers ( void )
Q3ListViewItemIterator it( mLayersListView );
int count = 0;
Q3ListViewItem *lastItem;
Q3ListViewItem *lastItem = NULL;
QString id;
while ( it.current() ) {
if ( it.current()->isSelected() ) {

View File

@ -232,7 +232,8 @@ void QgsGraduatedSymbolDialog::adjustClassification()
mClassListWidget->clear();
QGis::VectorType m_type = mVectorLayer->vectorType();
QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider *>(mVectorLayer->getDataProvider());
double minimum, maximum;
double minimum = 0;
double maximum = 0;
//delete all previous entries
for(std::map<QString, QgsSymbol*>::iterator it=mEntries.begin();it!=mEntries.end();++it)

View File

@ -119,10 +119,10 @@ void QgsMapToolAddFeature::canvasReleaseEvent(QMouseEvent * e)
// snap point to points within the vector layer snapping tolerance
vlayer->snapPoint(savePoint, tolerance);
int size;
int size = 0;
char end=QgsApplication::endian();
unsigned char *wkb;
int wkbtype;
unsigned char *wkb = NULL;
int wkbtype = 0;
double x = savePoint.x();
double y = savePoint.y();

View File

@ -73,9 +73,7 @@ SET_SOURCE_FILES_PROPERTIES(
SET(QGIS_CORE_MOC_HDRS
qgscontexthelp.h
qgscoordinatetransform.h
qgscsexception.h
qgsdataprovider.h
qgsexception.h
qgshttptransaction.h
qgsmaplayer.h
qgsmaplayerregistry.h
@ -87,9 +85,6 @@ qgsrunprocess.h
qgsvectorlayer.h
raster/qgsrasterlayer.h
raster/qgscolortable.h
raster/qgsrasterpyramid.h
raster/qgsrasterbandstats.h
raster/qgsrasterviewport.h
)

View File

@ -440,9 +440,17 @@ double QgsDistanceArea::computeDistanceBearing(
double lambda = L;
double lambdaP = 2*M_PI;
double sinLambda, cosLambda, sinSigma, cosSigma;
double sigma, alpha, cosSqAlpha, cos2SigmaM, C;
double tu1, tu2;
double sinLambda=0;
double cosLambda=0;
double sinSigma=0;
double cosSigma=0;
double sigma=0;
double alpha=0;
double cosSqAlpha=0;
double cos2SigmaM=0;
double C=0;
double tu1=0;
double tu2=0;
int iterLimit = 20;
while (fabs(lambda-lambdaP) > 1e-12 && --iterLimit>0)

View File

@ -379,7 +379,8 @@ QgsPoint QgsGeometry::closestVertex(const QgsPoint& point, QgsGeometryVertexInde
int vertexcounter = 0;
QGis::WKBTYPE wkbType;
double actdist = std::numeric_limits<double>::max();
double x,y;
double x=0;
double y=0;
double *tempx,*tempy;
memcpy(&wkbType, (mGeometry+1), sizeof(int));
beforeVertex = -1;
@ -2057,8 +2058,10 @@ double QgsGeometry::closestSegmentWithContext(const QgsPoint& point,
QGis::WKBTYPE wkbType;
bool hasZValue = false;
double *thisx,*thisy;
double *prevx,*prevy;
double *thisx = NULL;
double *thisy = NULL;
double *prevx = NULL;
double *prevy = NULL;
double testdist;
int closestSegmentIndex = 0;

View File

@ -204,7 +204,8 @@ void QgsLabel::renderLabel( QPainter * painter, QgsRect &viewExtent,
QFontMetrics fm ( font );
int width = fm.width ( text );
int height = fm.height();
int dx, dy;
int dx = 0;
int dy = 0;
value = fieldValue ( Alignment, feature );
if ( value.isEmpty() )

View File

@ -241,8 +241,8 @@ QgsProject * QgsProject::theProject_;
{
QgsPropertyKey * currentProperty = &rootProperty;
QgsProperty * nextProperty; // link to next property down hiearchy
QgsPropertyKey * previousQgsPropertyKey; // link to previous property up hiearchy
QgsProperty * nextProperty = NULL; // link to next property down hiearchy
QgsPropertyKey * previousQgsPropertyKey = NULL; // link to previous property up hiearchy
QStringList keySequence = makeKeyTokens_( scope, key );
@ -679,7 +679,7 @@ static std::pair< bool, std::list<QDomNode> > _getMapLayers(QDomDocument const &
QgsDebugMsg("Layer type is " + type);
QgsMapLayer *mapLayer;
QgsMapLayer *mapLayer = NULL;
if (type == "vector")
{

View File

@ -352,18 +352,18 @@ bool QgsPropertyValue::writeXML( QString const & nodeName,
QgsPropertyKey::QgsPropertyKey( QString const name )
: name_( name )
: mName( name )
{
// since we own our properties, we are responsible for deleting the
// contents
properties_.setAutoDelete(true);
mProperties.setAutoDelete(true);
}
QVariant QgsPropertyKey::value() const
{
QgsProperty * foundQgsProperty;
if ( 0 == ( foundQgsProperty = properties_.find(name()) ) )
if ( 0 == ( foundQgsProperty = mProperties.find(name()) ) )
{ // recurse down to next key
return foundQgsProperty->value();
} else
@ -386,9 +386,9 @@ void QgsPropertyKey::dump( size_t tabs ) const
tabs++;
tabString.fill( '\t', tabs );
if ( ! properties_.isEmpty() )
if ( ! mProperties.isEmpty() )
{
for (Q3DictIterator < QgsProperty > i(properties_); i.current(); ++i)
for (Q3DictIterator < QgsProperty > i(mProperties); i.current(); ++i)
{
if ( i.current()->isValue() )
{
@ -453,11 +453,11 @@ bool QgsPropertyKey::readXML(QDomNode & keyNode)
subkeys.item(i).isElement() && // and we're an element
subkeys.item(i).toElement().hasAttribute("type")) // and we have a "type" attribute
{ // then we're a key value
properties_.replace(subkeys.item(i).nodeName(), new QgsPropertyValue);
mProperties.replace(subkeys.item(i).nodeName(), new QgsPropertyValue);
QDomNode subkey = subkeys.item(i);
if (!properties_[subkeys.item(i).nodeName()]->readXML(subkey))
if (!mProperties[subkeys.item(i).nodeName()]->readXML(subkey))
{
qDebug("%s:%d unable to parse key value %s", __FILE__, __LINE__,
(const char *) subkeys.item(i).nodeName().utf8());
@ -469,7 +469,7 @@ bool QgsPropertyKey::readXML(QDomNode & keyNode)
QDomNode subkey = subkeys.item(i);
if (!properties_[subkeys.item(i).nodeName()]->readXML(subkey))
if (!mProperties[subkeys.item(i).nodeName()]->readXML(subkey))
{
qDebug("%s:%d unable to parse subkey %s", __FILE__, __LINE__,
(const char *) subkeys.item(i).nodeName().utf8());
@ -494,9 +494,9 @@ bool QgsPropertyKey::writeXML(QString const &nodeName, QDomElement & element, QD
QDomElement keyElement = document.createElement(nodeName); // DOM element for this property key
if ( ! properties_.isEmpty() )
if ( ! mProperties.isEmpty() )
{
for (Q3DictIterator < QgsProperty > i(properties_); i.current(); ++i)
for (Q3DictIterator < QgsProperty > i(mProperties); i.current(); ++i)
{
if (!i.current()->writeXML(i.currentKey(), keyElement, document))
{
@ -517,7 +517,7 @@ bool QgsPropertyKey::writeXML(QString const &nodeName, QDomElement & element, QD
void QgsPropertyKey::entryList( QStringList & entries ) const
{
// now add any leaf nodes to the entries list
for (Q3DictIterator<QgsProperty> i(properties_); i.current(); ++i)
for (Q3DictIterator<QgsProperty> i(mProperties); i.current(); ++i)
{
// add any of the nodes that have just a single value
if (i.current()->isLeaf())
@ -532,7 +532,7 @@ void QgsPropertyKey::entryList( QStringList & entries ) const
void QgsPropertyKey::subkeyList(QStringList & entries) const
{
// now add any leaf nodes to the entries list
for (Q3DictIterator < QgsProperty > i(properties_); i.current(); ++i)
for (Q3DictIterator < QgsProperty > i(mProperties); i.current(); ++i)
{
// add any of the nodes that have just a single value
if (!i.current()->isLeaf())
@ -551,7 +551,7 @@ bool QgsPropertyKey::isLeaf() const
}
else if (1 == count())
{
Q3DictIterator < QgsProperty > i(properties_);
Q3DictIterator < QgsProperty > i(mProperties);
if (i.current() && i.current()->isValue())
{

View File

@ -186,13 +186,13 @@ private:
Can, itself, contain QgsPropertyKeys and QgsPropertyValues.
The internal QDict, properties_, maps key names to their respective
The internal QDict, mProperties, maps key names to their respective
QgsPropertyValue or next QgsPropertyKey in the key name sequence. The key with
the current name should contain its QgsPropertyValue.
E.g., given the key sequence "/foo/bar", "foo" will have a corresponding
QgsPropertyKey with a name "foo". It will contain an element in its
properties_ that maps to "bar", which is another QgsPropertyKey. The "bar"
mProperties that maps to "bar", which is another QgsPropertyKey. The "bar"
QgsPropertyKey will, in turn, have an element that maps to itself, i.e. "bar",
that will contain a QgsPropertyValue.
@ -209,10 +209,10 @@ public:
/// every key has a name
// @{
QString const & name() const
{ return name_; }
{ return mName; }
QString & name()
{ return name_; }
{ return mName; }
// @}
@ -225,16 +225,16 @@ public:
/// add the given property key
QgsPropertyKey * addKey( QString const & keyName )
{
properties_.replace( keyName, new QgsPropertyKey(keyName) );
mProperties.replace( keyName, new QgsPropertyKey(keyName) );
return dynamic_cast<QgsPropertyKey*>(properties_.find( keyName ));
return dynamic_cast<QgsPropertyKey*>(mProperties.find( keyName ));
}
/// remove the given key
bool removeKey( QString const & keyName )
{
return properties_.remove( keyName );
return mProperties.remove( keyName );
}
/** set the value associated with this key
@ -242,9 +242,9 @@ public:
*/
QgsPropertyValue * setValue( QString const & name, QVariant const & value )
{
properties_.replace( name, new QgsPropertyValue( value ) );
mProperties.replace( name, new QgsPropertyValue( value ) );
return dynamic_cast<QgsPropertyValue*>(properties_.find( name ));
return dynamic_cast<QgsPropertyValue*>(mProperties.find( name ));
}
/** set the value associated with this key
@ -267,11 +267,11 @@ public:
/// how many elements are contained within this one?
size_t count() const
{ return properties_.count(); }
{ return mProperties.count(); }
/// Does this property not have any subkeys or values?
/* virtual */ bool isEmpty() const
{ return properties_.isEmpty(); }
{ return mProperties.isEmpty(); }
/** returns true if is a QgsPropertyKey */
virtual bool isKey() const
@ -297,28 +297,28 @@ public:
/// reset the QgsProperty key to prestine state
virtual void clear()
{
name_ = "";
properties_.clear();
mName = "";
mProperties.clear();
}
/// delete any sub-nodes
virtual void clearKeys()
{
properties_.clear();
mProperties.clear();
}
QgsProperty * find( QString & propertyName )
{
return properties_.find( propertyName );
return mProperties.find( propertyName );
}
private:
/// every key has a name
QString name_;
QString mName;
/// sub-keys
Q3Dict < QgsProperty > properties_;
Q3Dict < QgsProperty > mProperties;
}; // class QgsPropertyKey

View File

@ -48,8 +48,8 @@ QGis::units QgsScaleCalculator::mapUnits() const
double QgsScaleCalculator::calculate(QgsRect &mapExtent, int canvasWidth)
{
double conversionFactor;
double delta;
double conversionFactor = 0;
double delta = 0;
// calculation is based on the map units and extent, the dpi of the
// users display, and the canvas width
switch(mMapUnits)

View File

@ -108,7 +108,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(const QString& shapefileName,
{
const QgsField& attrField = fldIt.value();
OGRFieldType ogrType;
OGRFieldType ogrType = OFTString; //default to string
switch (attrField.type())
{
case QVariant::String:

View File

@ -2008,7 +2008,7 @@ void QgsRasterLayer::drawPalettedSingleBandPseudoColor(QPainter * theQPainter, Q
bool found = myColorTable->color ( myValDouble, &c1, &c2, &c3 );
if ( !found ) continue;
int myInt;
int myInt=0;
//check for alternate color mappings
if (theColorQString == redBandNameQString)
@ -2343,9 +2343,9 @@ void QgsRasterLayer::drawMultiBandColor(QPainter * theQPainter, QgsRasterViewPor
}
bool haveTransparencyBand(false);
GDALRasterBand *myGdalTransparentBand;
GDALDataType myTransparentType;
void *myGdalTransparentData;
GDALRasterBand *myGdalTransparentBand = NULL;
GDALDataType myTransparentType = GDT_Byte; //default to prevent uninitialised var warnings
void *myGdalTransparentData = NULL;
if (transparentBandNameQString != tr("Not Set"))
{

View File

@ -4,6 +4,12 @@ SUBDIRS(config modules themes)
ADD_DEFINITIONS(-DGRASS_BASE=\\\"${GRASS_PREFIX}\\\")
ADD_DEFINITIONS(-DHAVE_OPENPTY=${HAVE_OPENPTY})
MESSAGE("providers/grass : -Werror removed for qgsgrassplugin.cpp for now - please get rid of any compiler warnings!")
# The warnings are caused by multiple definitions of NDEBUG in grass sources
# I have submitted a bug to teh grass folks in the meantime we need to
# disable treating warnings as errors for the affected files
FILE (GLOB files *.cpp)
SET_SOURCE_FILES_PROPERTIES(${files} PROPERTIES COMPILE_FLAGS -Wno-error )
########################################################
# Files
@ -64,6 +70,20 @@ QT4_WRAP_CPP (GRASS_PLUGIN_MOC_SRCS ${GRASS_PLUGIN_MOC_HDRS})
#QT4_ADD_RESOURCES(GRASS_PLUGIN_RCC_SRCS ${GRASS_PLUGIN_RCCS})
########################################################
# deal with warnings
MESSAGE("providers/grass : -Werror removed for qgsgrassplugin.cpp for now - please get rid of any compiler warnings!")
# The warnings are caused by multiple definitions of NDEBUG in grass sources
# I have submitted a bug to teh grass folks in the meantime we need to
# disable treating warnings as errors for the affected files
FILE (GLOB files *.cpp)
SET_SOURCE_FILES_PROPERTIES(${files} PROPERTIES COMPILE_FLAGS -Wno-error )
SET_SOURCE_FILES_PROPERTIES(${GRASS_PLUGIN_MOC_SRCS} PROPERTIES COMPILE_FLAGS -Wno-error )
########################################################
# build lib
ADD_LIBRARY (grassplugin MODULE ${GRASS_PLUGIN_SRCS} ${GRASS_PLUGIN_MOC_SRCS} ${GRASS_PLUGIN_UIS_H})
INCLUDE_DIRECTORIES(

View File

@ -468,7 +468,7 @@ bool QgsGrassBrowser::getItemRegion( QModelIndex index, struct Cell_head *window
QString mapset = mModel->itemMapset(index);
QString map = mModel->itemMap(index);
int mapType;
int mapType = QgsGrass::Raster; //default in case no case matches
switch (type) {
case QgsGrassModel::Raster :
mapType = QgsGrass::Raster;

View File

@ -1198,8 +1198,9 @@ void QgsGrassEdit::snap ( QgsPoint & point, double startX, double startY )
if ( startDist <= thresh ) startIn = true;
// Nearest node
double nodeX, nodeY;
double nodeDist;
double nodeX = 0;
double nodeY = 0;
double nodeDist = 0;
bool nodeIn = false;
int node = mProvider->findNode ( x, y, thresh );

View File

@ -677,7 +677,7 @@ void QgsGrassModel::refreshItem(QgsGrassModelItem *item)
case QgsGrassModel::Regions:
{
QStringList list;
int type;
int type = 0;
if ( item->mType == QgsGrassModel::Vectors )
{
list = QgsGrass::vectors ( item->mGisbase, item->mLocation,

View File

@ -8,6 +8,13 @@ SET(GRASS_PROVIDER_SRCS provider.cpp)
SET(GRASS_LIB_SRCS qgsgrassprovider.cpp qgsgrass.cpp)
MESSAGE("providers/grass : -Werror removed for qgsgrassprovider.cpp for now - please get rid of any compiler warnings!")
# The warnings are caused by multiple definitions of NDEBUG in grass sources
# I have submitted a bug to teh grass folks in the meantime we need to
# disable treating warnings as errors for the affected files
SET_SOURCE_FILES_PROPERTIES(qgsgrassprovider.cpp PROPERTIES COMPILE_FLAGS -Wno-error )
SET_SOURCE_FILES_PROPERTIES(qgsgrass.cpp PROPERTIES COMPILE_FLAGS -Wno-error )
SET_SOURCE_FILES_PROPERTIES(provider.cpp PROPERTIES COMPILE_FLAGS -Wno-error )
########################################################
# Build

View File

@ -753,7 +753,7 @@ void QgsGrassProvider::loadAttributes ( GLAYER &layer )
dbColumn *column = db_get_table_column (databaseTable, i);
int ctype = db_sqltype_to_Ctype ( db_get_column_sqltype(column) );
QVariant::Type qtype;
QVariant::Type qtype = QVariant::String; //default to string
#ifdef QGISDEBUG
std::cerr << "column = " << db_get_column_name(column)
<< " ctype = " << ctype << std::endl;
@ -1831,7 +1831,7 @@ std::vector<QgsField> *QgsGrassProvider::columns ( int field )
int ctype = db_sqltype_to_Ctype( db_get_column_sqltype (column) );
QString type;
QVariant::Type qtype;
QVariant::Type qtype = QVariant::String; //default to string to prevent compiler warnings
switch ( ctype ) {
case DB_C_TYPE_INT:
type = "int";