Skip to content

Commit b67daf0

Browse files
committed
new coverity fixes
1 parent b2cfe0b commit b67daf0

39 files changed

+489
-352
lines changed

src/analysis/raster/qgsninecellfilter.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,25 @@
2727
#endif
2828

2929
QgsNineCellFilter::QgsNineCellFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat )
30-
: mInputFile( inputFile ), mOutputFile( outputFile ), mOutputFormat( outputFormat ), mCellSizeX( -1 ), mCellSizeY( -1 ),
31-
mInputNodataValue( -1 ), mOutputNodataValue( -1 ), mZFactor( 1.0 )
30+
: mInputFile( inputFile )
31+
, mOutputFile( outputFile )
32+
, mOutputFormat( outputFormat )
33+
, mCellSizeX( 0 )
34+
, mCellSizeY( 0 )
35+
, mInputNodataValue( 0 )
36+
, mOutputNodataValue( 0 )
37+
, mZFactor( 1.0 )
3238
{
3339

3440
}
3541

3642
QgsNineCellFilter::QgsNineCellFilter()
43+
: mCellSizeX( 0 )
44+
, mCellSizeY( 0 )
45+
, mInputNodataValue( 0 )
46+
, mOutputNodataValue( 0 )
47+
, mZFactor( 1.0 )
3748
{
38-
3949
}
4050

4151
QgsNineCellFilter::~QgsNineCellFilter()

src/app/main.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ static void dumpBacktrace( unsigned int depth )
210210
int stderr_new = dup( fd[1] );
211211
if ( stderr_new != STDERR_FILENO )
212212
{
213-
close( stderr_new );
213+
if ( stderr_new >= 0 )
214+
close( stderr_new );
214215
QgsDebugMsg( "dup to stderr failed" );
215216
}
216217

src/app/qgisapp.cpp

+28-5
Original file line numberDiff line numberDiff line change
@@ -478,15 +478,39 @@ QgisApp *QgisApp::smInstance = 0;
478478
// constructor starts here
479479
QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent, Qt::WindowFlags fl )
480480
: QMainWindow( parent, fl )
481-
, mSplash( splash )
482481
, mMousePrecisionDecimalPlaces( 0 )
483-
, mInternalClipboard( 0 )
484-
, mShowProjectionTab( false )
485-
, mPythonUtils( 0 )
486482
#ifdef Q_OS_WIN
487483
, mSkipNextContextMenuEvent( 0 )
488484
#endif
485+
, mNonEditMapTool( 0 )
486+
, mScaleLabel( 0 )
487+
, mScaleEdit( 0 )
488+
, mScaleEditValidator( 0 )
489+
, mCoordsLabel( 0 )
490+
, mCoordsEdit( 0 )
491+
, mCoordsEditValidator( 0 )
492+
, mRotationLabel( 0 )
493+
, mRotationEdit( 0 )
494+
, mRotationEditValidator( 0 )
495+
, mProgressBar( 0 )
496+
, mRenderSuppressionCBox( 0 )
497+
, mOnTheFlyProjectionStatusLabel( 0 )
498+
, mOnTheFlyProjectionStatusButton( 0 )
499+
, mMessageButton( 0 )
500+
, mFeatureActionMenu( 0 )
501+
, mPopupMenu( 0 )
502+
, mDatabaseMenu( 0 )
503+
, mWebMenu( 0 )
504+
, mToolPopupOverviews( 0 )
505+
, mToolPopupDisplay( 0 )
506+
, mLayerTreeCanvasBridge( 0 )
507+
, mPreviousNonZoomMapTool( 0 )
508+
, mSplash( splash )
509+
, mInternalClipboard( 0 )
510+
, mShowProjectionTab( false )
511+
, mPythonUtils( 0 )
489512
, mComposerManager( 0 )
513+
, mpTileScaleWidget( 0 )
490514
, mpGpsWidget( 0 )
491515
, mSnappingUtils( 0 )
492516
{
@@ -842,7 +866,6 @@ QgisApp::QgisApp()
842866
, mSnappingDialog( 0 )
843867
, mPluginManager( 0 )
844868
, mComposerManager( 0 )
845-
, mpTileScaleWidget( 0 )
846869
, mLastComposerId( 0 )
847870
, mpGpsWidget( 0 )
848871
, mLastMapToolMessage( 0 )

src/app/qgisapp.h

+155-158
Large diffs are not rendered by default.

src/core/raster/qgsrasterlayer.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
192192
*
193193
* -
194194
* */
195-
QgsRasterLayer( const QString & path,
196-
const QString & baseName = QString::null,
195+
QgsRasterLayer( const QString &path,
196+
const QString &baseName = QString::null,
197197
bool loadDefaultStyleFlag = true );
198198

199199
//TODO - QGIS 3.0
@@ -202,9 +202,9 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
202202
//implicitly converted to a bool.
203203
//for QGIS 3.0, make either constructor explicit or alter the signatures
204204
/** \brief [ data provider interface ] Constructor in provider mode */
205-
QgsRasterLayer( const QString & uri,
206-
const QString & baseName,
207-
const QString & providerKey,
205+
QgsRasterLayer( const QString &uri,
206+
const QString &baseName,
207+
const QString &providerKey,
208208
bool loadDefaultStyleFlag = true );
209209

210210
/** \brief The destructor */

src/gui/editorwidgets/qgsrelationreferencewidget.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ QgsRelationReferenceWidget::QgsRelationReferenceWidget( QWidget* parent )
7474
, mEmbedForm( false )
7575
, mReadOnlySelector( false )
7676
, mAllowMapIdentification( false )
77+
, mOrderByValue( false )
7778
, mOpenFormButtonVisible( true )
7879
{
7980
mTopLayout = new QVBoxLayout( this );

src/plugins/grass/qgsgrassedit.cpp

+21-8
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,33 @@ void QgsGrassEditAttributeTableItemDelegate::setModelData( QWidget *editor,
143143

144144
bool QgsGrassEdit::mRunning = false;
145145

146-
QgsGrassEdit::QgsGrassEdit( QgisInterface *iface, QgsMapLayer* layer, bool newMap,
147-
QWidget * parent, Qt::WindowFlags f )
148-
: QMainWindow( parent, f ), QgsGrassEditBase(), mInited( false ),
149-
mMapTool( 0 ), mCanvasEdit( 0 ), mRubberBandLine( 0 ), mRubberBandIcon( 0 )
146+
QgsGrassEdit::QgsGrassEdit( QgisInterface *iface, QgsMapLayer *layer, bool newMap,
147+
QWidget *parent, Qt::WindowFlags f )
148+
: QMainWindow( parent, f )
149+
, QgsGrassEditBase()
150+
, mValid( false )
151+
, mInited( false )
152+
, mIface( iface )
153+
, mMoveVertexAction( 0 )
154+
, mAddVertexAction( 0 )
155+
, mDeleteVertexAction( 0 )
156+
, mMoveLineAction( 0 )
157+
, mSplitLineAction( 0 )
158+
, mDeleteLineAction( 0 )
159+
, mEditAttributesAction( 0 )
160+
, mCloseEditAction( 0 )
161+
, mMapTool( 0 )
162+
, mCanvasEdit( 0 )
163+
, mRubberBandLine( 0 )
164+
, mRubberBandIcon( 0 )
150165
{
151166
QgsDebugMsg( "QgsGrassEdit()" );
152167

153168
setupUi( this );
154169

155170
mRunning = true;
156-
mValid = false;
157171
mTool = QgsGrassEdit::NONE;
158172
mSuspend = false;
159-
mIface = iface;
160173
mNewMap = newMap;
161174

162175
mProjectionEnabled = ( QgsProject::instance()->readNumEntry( "SpatialRefSys", "/ProjectionsEnabled", 0 ) != 0 );
@@ -173,7 +186,6 @@ QgsGrassEdit::QgsGrassEdit( QgisInterface *iface, QgsMapLayer* layer, bool newMa
173186
mProvider = ( QgsGrassProvider * ) mLayer->dataProvider();
174187

175188
init();
176-
177189
}
178190

179191
bool QgsGrassEdit::isEditable( QgsMapLayer *layer )
@@ -1531,7 +1543,8 @@ void QgsGrassEdit::addCat( int line )
15311543
delete atts;
15321544
}
15331545

1534-
addAttributes( field, cat );
1546+
if ( mAttributes )
1547+
addAttributes( field, cat );
15351548
}
15361549

15371550
void QgsGrassEdit::deleteCat( int line, int field, int cat )

src/plugins/grass/qgsgrassedit.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ class QgsGrassEdit: public QMainWindow, private Ui::QgsGrassEditBase
444444
bool mProjectionEnabled;
445445

446446
// Canvas items
447-
QgsGrassEditLayer* mCanvasEdit;
447+
QgsGrassEditLayer *mCanvasEdit;
448448
QgsRubberBand *mRubberBandLine;
449449
QgsVertexMarker *mRubberBandIcon;
450450

src/plugins/grass/qgsgrassmapcalc.cpp

+30-26
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "qgsgrassplugin.h"
2626

2727
#include <cmath>
28-
#include <typeinfo>
2928

3029
#include <QDir>
3130
#include <QDomDocument>
@@ -280,19 +279,19 @@ void QgsGrassMapcalc::mousePressEvent( QMouseEvent* e )
280279
{
281280
--it;
282281

283-
if ( typeid( **it ) == typeid( QgsGrassMapcalcConnector ) )
282+
if ( QgsGrassMapcalcConnector *con = dynamic_cast<QgsGrassMapcalcConnector *>( *it ) )
284283
{
285-
mConnector = dynamic_cast<QgsGrassMapcalcConnector *>( *it );
284+
mConnector = con;
286285
mConnector->setSelected( true );
287286
mConnector->selectEnd( p );
288287
mStartMoveConnectorPoints[0] = mConnector->point( 0 );
289288
mStartMoveConnectorPoints[1] = mConnector->point( 1 );
290289

291290
break;
292291
}
293-
else if ( typeid( **it ) == typeid( QgsGrassMapcalcObject ) )
292+
else if ( QgsGrassMapcalcObject *obj = dynamic_cast<QgsGrassMapcalcObject *>( *it ) )
294293
{
295-
mObject = dynamic_cast<QgsGrassMapcalcObject *>( *it );
294+
mObject = obj;
296295
mObject->setSelected( true );
297296

298297
int tool = Select;
@@ -991,17 +990,13 @@ void QgsGrassMapcalc::growCanvas( int left, int right, int top, int bottom )
991990
{
992991
--it;
993992

994-
if ( typeid( **it ) == typeid( QgsGrassMapcalcObject ) )
993+
if ( QgsGrassMapcalcObject *obj = dynamic_cast<QgsGrassMapcalcObject *>( *it ) )
995994
{
996-
QgsGrassMapcalcObject *obj = dynamic_cast<QgsGrassMapcalcObject *>( *it );
997-
998995
QPoint p = obj->center();
999996
obj->setCenter( p.x() + left, p.y() + top );
1000997
}
1001-
else if ( typeid( **it ) == typeid( QgsGrassMapcalcConnector ) )
998+
else if ( QgsGrassMapcalcConnector *con = dynamic_cast<QgsGrassMapcalcConnector *>( *it ) )
1002999
{
1003-
QgsGrassMapcalcConnector *con = dynamic_cast<QgsGrassMapcalcConnector *>( *it );
1004-
10051000
for ( int i = 0; i < 2; i++ )
10061001
{
10071002
QPoint p = con->point( i );
@@ -1162,10 +1157,8 @@ void QgsGrassMapcalc::save()
11621157
{
11631158
--it;
11641159

1165-
if ( typeid( **it ) == typeid( QgsGrassMapcalcObject ) )
1160+
if ( QgsGrassMapcalcObject *obj = dynamic_cast<QgsGrassMapcalcObject *>( *it ) )
11661161
{
1167-
QgsGrassMapcalcObject *obj = dynamic_cast<QgsGrassMapcalcObject *>( *it );
1168-
11691162
QString type;
11701163
if ( obj->type() == QgsGrassMapcalcObject::Map )
11711164
{
@@ -1212,10 +1205,8 @@ void QgsGrassMapcalc::save()
12121205
}
12131206
stream << "/>\n";
12141207
}
1215-
else if ( typeid( **it ) == typeid( QgsGrassMapcalcConnector ) )
1208+
else if ( QgsGrassMapcalcConnector *con = dynamic_cast<QgsGrassMapcalcConnector *>( *it ) )
12161209
{
1217-
QgsGrassMapcalcConnector *con = dynamic_cast<QgsGrassMapcalcConnector *>( *it );
1218-
12191210
stream << " <connector id=\"" + QString::number( con->id() )
12201211
+ "\">\n";
12211212

@@ -1914,7 +1905,9 @@ QString QgsGrassMapcalcObject::expression()
19141905

19151906
/************************* CONNECTOR **********************************/
19161907
QgsGrassMapcalcConnector::QgsGrassMapcalcConnector( QGraphicsScene *canvas )
1917-
: QGraphicsLineItem(), QgsGrassMapcalcItem()
1908+
: QGraphicsLineItem()
1909+
, QgsGrassMapcalcItem()
1910+
, mSelectedEnd( -1 )
19181911
{
19191912
QgsDebugMsg( "entered." );
19201913

@@ -2042,11 +2035,8 @@ bool QgsGrassMapcalcConnector::tryConnectEnd( int end )
20422035
{
20432036
--it;
20442037

2045-
if ( typeid( **it ) == typeid( QgsGrassMapcalcObject ) )
2046-
{
2047-
object = dynamic_cast<QgsGrassMapcalcObject *>( *it );
2038+
if (( object = dynamic_cast<QgsGrassMapcalcObject *>( *it ) ) )
20482039
break;
2049-
}
20502040
}
20512041

20522042
// try to connect
@@ -2117,10 +2107,13 @@ QgsGrassMapcalcObject *QgsGrassMapcalcConnector::object( int end )
21172107
/************************* FUNCTION *****************************/
21182108
QgsGrassMapcalcFunction::QgsGrassMapcalcFunction( int type, QString name,
21192109
int count, QString description, QString label, QString labels,
2120-
bool drawLabel ) :
2121-
mName( name ), mType( type ), mInputCount( count ),
2122-
mLabel( label ), mDescription( description ),
2123-
mDrawLabel( drawLabel )
2110+
bool drawLabel )
2111+
: mName( name )
2112+
, mType( type )
2113+
, mInputCount( count )
2114+
, mLabel( label )
2115+
, mDescription( description )
2116+
, mDrawLabel( drawLabel )
21242117
{
21252118
if ( mLabel.isEmpty() )
21262119
mLabel = mName;
@@ -2131,6 +2124,17 @@ QgsGrassMapcalcFunction::QgsGrassMapcalcFunction( int type, QString name,
21312124
}
21322125
}
21332126

2127+
QgsGrassMapcalcFunction::QgsGrassMapcalcFunction()
2128+
: mType( 0 )
2129+
, mInputCount( 0 )
2130+
, mDrawLabel( false )
2131+
{
2132+
}
2133+
2134+
QgsGrassMapcalcFunction::~QgsGrassMapcalcFunction()
2135+
{
2136+
}
2137+
21342138
/******************** CANVAS VIEW ******************************/
21352139

21362140
QgsGrassMapcalcView::QgsGrassMapcalcView( QgsGrassMapcalc * mapcalc,

src/plugins/grass/qgsgrassmapcalc.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,11 @@ class QgsGrassMapcalcFunction
219219
Function
220220
};
221221

222-
QgsGrassMapcalcFunction() {};
222+
QgsGrassMapcalcFunction();
223223
QgsGrassMapcalcFunction( int type, QString name, int count = 2,
224224
QString description = "", QString label = "",
225225
QString labels = "", bool drawLabel = true );
226-
~QgsGrassMapcalcFunction() {};
226+
~QgsGrassMapcalcFunction();
227227

228228
QString name() { return mName; }
229229
int type() { return mType; }

src/plugins/grass/qgsgrassmodule.cpp

+20-4
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,11 @@ QStringList QgsGrassModule::execArguments( QString module )
149149
}
150150

151151
QgsGrassModule::QgsGrassModule( QgsGrassTools *tools, QString moduleName, QgisInterface *iface,
152-
QString path, bool direct, QWidget * parent, Qt::WindowFlags f )
153-
: QgsGrassModuleBase(), mSuccess( false ), mDirect( direct )
152+
QString path, bool direct, QWidget *parent, Qt::WindowFlags f )
153+
: QgsGrassModuleBase()
154+
, mOptions( 0 )
155+
, mSuccess( false )
156+
, mDirect( direct )
154157
{
155158
Q_UNUSED( f );
156159
QgsDebugMsg( "called" );
@@ -2033,8 +2036,18 @@ void QgsGrassModule::setDirectLibraryPath( QProcessEnvironment & environment )
20332036
QgsGrassModuleOption::QgsGrassModuleOption( QgsGrassModule *module, QString key,
20342037
QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode,
20352038
bool direct, QWidget * parent )
2036-
: QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, direct, parent ),
2037-
mControlType( NoControl ), mValueType( String ), mOutputType( None ), mHaveLimits( false ), mIsOutput( false )
2039+
: QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, direct, parent )
2040+
, mControlType( NoControl )
2041+
, mValueType( String )
2042+
, mOutputType( None )
2043+
, mHaveLimits( false )
2044+
, mMin( INT_MAX )
2045+
, mMax( INT_MIN )
2046+
, mComboBox( 0 )
2047+
, mIsOutput( false )
2048+
, mValidator( 0 )
2049+
, mLayout( 0 )
2050+
, mUsesRegion( false )
20382051
{
20392052
QgsDebugMsg( "called." );
20402053
setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum );
@@ -2540,11 +2553,14 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module,
25402553
QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode,
25412554
bool direct, QWidget * parent )
25422555
: QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, direct, parent )
2556+
, mType( QgsGrassModuleInput::Vector )
25432557
, mModuleStandardOptions( options )
25442558
, mGeometryTypeOption( "" )
25452559
, mVectorLayerOption( "" )
2560+
, mLayerComboBox( 0 )
25462561
, mRegionButton( 0 )
25472562
, mUpdate( false )
2563+
, mUsesRegion( false )
25482564
, mRequired( false )
25492565
{
25502566
QgsDebugMsg( "called." );

0 commit comments

Comments
 (0)