Skip to content

Commit

Permalink
Fixed compiler warnings:
Browse files Browse the repository at this point in the history
 - 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/qgis@7059 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Jul 4, 2007
1 parent 684f671 commit 07b1bbe
Show file tree
Hide file tree
Showing 22 changed files with 108 additions and 72 deletions.
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposer.cpp
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/app/composer/qgscomposermap.cpp
Expand Up @@ -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 :
Expand All @@ -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 :
Expand Down
8 changes: 4 additions & 4 deletions src/app/composer/qgscomposerscalebar.cpp
Expand Up @@ -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 {
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/app/composer/qgscomposervectorlegend.cpp
Expand Up @@ -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 {
Expand Down Expand Up @@ -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() ) {
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgsgraduatedsymboldialog.cpp
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgsmaptooladdfeature.cpp
Expand Up @@ -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();

Expand Down
5 changes: 0 additions & 5 deletions src/core/CMakeLists.txt
Expand Up @@ -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
Expand All @@ -87,9 +85,6 @@ qgsrunprocess.h
qgsvectorlayer.h

raster/qgsrasterlayer.h
raster/qgscolortable.h
raster/qgsrasterpyramid.h
raster/qgsrasterbandstats.h
raster/qgsrasterviewport.h
)

Expand Down
14 changes: 11 additions & 3 deletions src/core/qgsdistancearea.cpp
Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions src/core/qgsgeometry.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion src/core/qgslabel.cpp
Expand Up @@ -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() )
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsproject.cpp
Expand Up @@ -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 );

Expand Down Expand Up @@ -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")
{
Expand Down
26 changes: 13 additions & 13 deletions src/core/qgsprojectproperty.cpp
Expand Up @@ -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
Expand All @@ -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() )
{
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand All @@ -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))
{
Expand All @@ -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())
Expand All @@ -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())
Expand All @@ -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())
{
Expand Down
34 changes: 17 additions & 17 deletions src/core/qgsprojectproperty.h
Expand Up @@ -186,13 +186,13 @@ class CORE_EXPORT QgsPropertyValue : public QgsProperty
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.
Expand All @@ -209,10 +209,10 @@ class CORE_EXPORT QgsPropertyKey : public QgsProperty
/// every key has a name
// @{
QString const & name() const
{ return name_; }
{ return mName; }

QString & name()
{ return name_; }
{ return mName; }
// @}


Expand All @@ -225,26 +225,26 @@ class CORE_EXPORT QgsPropertyKey : public QgsProperty
/// 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
@param name is the key name
*/
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
Expand All @@ -267,11 +267,11 @@ class CORE_EXPORT QgsPropertyKey : public QgsProperty

/// 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
Expand All @@ -297,28 +297,28 @@ class CORE_EXPORT QgsPropertyKey : public QgsProperty
/// 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

Expand Down

0 comments on commit 07b1bbe

Please sign in to comment.