Skip to content

Commit

Permalink
new coverity fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 8, 2015
1 parent b2cfe0b commit b67daf0
Show file tree
Hide file tree
Showing 39 changed files with 489 additions and 352 deletions.
16 changes: 13 additions & 3 deletions src/analysis/raster/qgsninecellfilter.cpp
Expand Up @@ -27,15 +27,25 @@
#endif

QgsNineCellFilter::QgsNineCellFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat )
: mInputFile( inputFile ), mOutputFile( outputFile ), mOutputFormat( outputFormat ), mCellSizeX( -1 ), mCellSizeY( -1 ),
mInputNodataValue( -1 ), mOutputNodataValue( -1 ), mZFactor( 1.0 )
: mInputFile( inputFile )
, mOutputFile( outputFile )
, mOutputFormat( outputFormat )
, mCellSizeX( 0 )
, mCellSizeY( 0 )
, mInputNodataValue( 0 )
, mOutputNodataValue( 0 )
, mZFactor( 1.0 )
{

}

QgsNineCellFilter::QgsNineCellFilter()
: mCellSizeX( 0 )
, mCellSizeY( 0 )
, mInputNodataValue( 0 )
, mOutputNodataValue( 0 )
, mZFactor( 1.0 )
{

}

QgsNineCellFilter::~QgsNineCellFilter()
Expand Down
3 changes: 2 additions & 1 deletion src/app/main.cpp
Expand Up @@ -210,7 +210,8 @@ static void dumpBacktrace( unsigned int depth )
int stderr_new = dup( fd[1] );
if ( stderr_new != STDERR_FILENO )
{
close( stderr_new );
if ( stderr_new >= 0 )
close( stderr_new );
QgsDebugMsg( "dup to stderr failed" );
}

Expand Down
33 changes: 28 additions & 5 deletions src/app/qgisapp.cpp
Expand Up @@ -478,15 +478,39 @@ QgisApp *QgisApp::smInstance = 0;
// constructor starts here
QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent, Qt::WindowFlags fl )
: QMainWindow( parent, fl )
, mSplash( splash )
, mMousePrecisionDecimalPlaces( 0 )
, mInternalClipboard( 0 )
, mShowProjectionTab( false )
, mPythonUtils( 0 )
#ifdef Q_OS_WIN
, mSkipNextContextMenuEvent( 0 )
#endif
, mNonEditMapTool( 0 )
, mScaleLabel( 0 )
, mScaleEdit( 0 )
, mScaleEditValidator( 0 )
, mCoordsLabel( 0 )
, mCoordsEdit( 0 )
, mCoordsEditValidator( 0 )
, mRotationLabel( 0 )
, mRotationEdit( 0 )
, mRotationEditValidator( 0 )
, mProgressBar( 0 )
, mRenderSuppressionCBox( 0 )
, mOnTheFlyProjectionStatusLabel( 0 )
, mOnTheFlyProjectionStatusButton( 0 )
, mMessageButton( 0 )
, mFeatureActionMenu( 0 )
, mPopupMenu( 0 )
, mDatabaseMenu( 0 )
, mWebMenu( 0 )
, mToolPopupOverviews( 0 )
, mToolPopupDisplay( 0 )
, mLayerTreeCanvasBridge( 0 )
, mPreviousNonZoomMapTool( 0 )
, mSplash( splash )
, mInternalClipboard( 0 )
, mShowProjectionTab( false )
, mPythonUtils( 0 )
, mComposerManager( 0 )
, mpTileScaleWidget( 0 )
, mpGpsWidget( 0 )
, mSnappingUtils( 0 )
{
Expand Down Expand Up @@ -842,7 +866,6 @@ QgisApp::QgisApp()
, mSnappingDialog( 0 )
, mPluginManager( 0 )
, mComposerManager( 0 )
, mpTileScaleWidget( 0 )
, mLastComposerId( 0 )
, mpGpsWidget( 0 )
, mLastMapToolMessage( 0 )
Expand Down
313 changes: 155 additions & 158 deletions src/app/qgisapp.h

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/core/raster/qgsrasterlayer.h
Expand Up @@ -192,8 +192,8 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
*
* -
* */
QgsRasterLayer( const QString & path,
const QString & baseName = QString::null,
QgsRasterLayer( const QString &path,
const QString &baseName = QString::null,
bool loadDefaultStyleFlag = true );

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

/** \brief The destructor */
Expand Down
1 change: 1 addition & 0 deletions src/gui/editorwidgets/qgsrelationreferencewidget.cpp
Expand Up @@ -74,6 +74,7 @@ QgsRelationReferenceWidget::QgsRelationReferenceWidget( QWidget* parent )
, mEmbedForm( false )
, mReadOnlySelector( false )
, mAllowMapIdentification( false )
, mOrderByValue( false )
, mOpenFormButtonVisible( true )
{
mTopLayout = new QVBoxLayout( this );
Expand Down
29 changes: 21 additions & 8 deletions src/plugins/grass/qgsgrassedit.cpp
Expand Up @@ -143,20 +143,33 @@ void QgsGrassEditAttributeTableItemDelegate::setModelData( QWidget *editor,

bool QgsGrassEdit::mRunning = false;

QgsGrassEdit::QgsGrassEdit( QgisInterface *iface, QgsMapLayer* layer, bool newMap,
QWidget * parent, Qt::WindowFlags f )
: QMainWindow( parent, f ), QgsGrassEditBase(), mInited( false ),
mMapTool( 0 ), mCanvasEdit( 0 ), mRubberBandLine( 0 ), mRubberBandIcon( 0 )
QgsGrassEdit::QgsGrassEdit( QgisInterface *iface, QgsMapLayer *layer, bool newMap,
QWidget *parent, Qt::WindowFlags f )
: QMainWindow( parent, f )
, QgsGrassEditBase()
, mValid( false )
, mInited( false )
, mIface( iface )
, mMoveVertexAction( 0 )
, mAddVertexAction( 0 )
, mDeleteVertexAction( 0 )
, mMoveLineAction( 0 )
, mSplitLineAction( 0 )
, mDeleteLineAction( 0 )
, mEditAttributesAction( 0 )
, mCloseEditAction( 0 )
, mMapTool( 0 )
, mCanvasEdit( 0 )
, mRubberBandLine( 0 )
, mRubberBandIcon( 0 )
{
QgsDebugMsg( "QgsGrassEdit()" );

setupUi( this );

mRunning = true;
mValid = false;
mTool = QgsGrassEdit::NONE;
mSuspend = false;
mIface = iface;
mNewMap = newMap;

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

init();

}

bool QgsGrassEdit::isEditable( QgsMapLayer *layer )
Expand Down Expand Up @@ -1531,7 +1543,8 @@ void QgsGrassEdit::addCat( int line )
delete atts;
}

addAttributes( field, cat );
if ( mAttributes )
addAttributes( field, cat );
}

void QgsGrassEdit::deleteCat( int line, int field, int cat )
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/grass/qgsgrassedit.h
Expand Up @@ -444,7 +444,7 @@ class QgsGrassEdit: public QMainWindow, private Ui::QgsGrassEditBase
bool mProjectionEnabled;

// Canvas items
QgsGrassEditLayer* mCanvasEdit;
QgsGrassEditLayer *mCanvasEdit;
QgsRubberBand *mRubberBandLine;
QgsVertexMarker *mRubberBandIcon;

Expand Down
56 changes: 30 additions & 26 deletions src/plugins/grass/qgsgrassmapcalc.cpp
Expand Up @@ -25,7 +25,6 @@
#include "qgsgrassplugin.h"

#include <cmath>
#include <typeinfo>

#include <QDir>
#include <QDomDocument>
Expand Down Expand Up @@ -280,19 +279,19 @@ void QgsGrassMapcalc::mousePressEvent( QMouseEvent* e )
{
--it;

if ( typeid( **it ) == typeid( QgsGrassMapcalcConnector ) )
if ( QgsGrassMapcalcConnector *con = dynamic_cast<QgsGrassMapcalcConnector *>( *it ) )
{
mConnector = dynamic_cast<QgsGrassMapcalcConnector *>( *it );
mConnector = con;
mConnector->setSelected( true );
mConnector->selectEnd( p );
mStartMoveConnectorPoints[0] = mConnector->point( 0 );
mStartMoveConnectorPoints[1] = mConnector->point( 1 );

break;
}
else if ( typeid( **it ) == typeid( QgsGrassMapcalcObject ) )
else if ( QgsGrassMapcalcObject *obj = dynamic_cast<QgsGrassMapcalcObject *>( *it ) )
{
mObject = dynamic_cast<QgsGrassMapcalcObject *>( *it );
mObject = obj;
mObject->setSelected( true );

int tool = Select;
Expand Down Expand Up @@ -991,17 +990,13 @@ void QgsGrassMapcalc::growCanvas( int left, int right, int top, int bottom )
{
--it;

if ( typeid( **it ) == typeid( QgsGrassMapcalcObject ) )
if ( QgsGrassMapcalcObject *obj = dynamic_cast<QgsGrassMapcalcObject *>( *it ) )
{
QgsGrassMapcalcObject *obj = dynamic_cast<QgsGrassMapcalcObject *>( *it );

QPoint p = obj->center();
obj->setCenter( p.x() + left, p.y() + top );
}
else if ( typeid( **it ) == typeid( QgsGrassMapcalcConnector ) )
else if ( QgsGrassMapcalcConnector *con = dynamic_cast<QgsGrassMapcalcConnector *>( *it ) )
{
QgsGrassMapcalcConnector *con = dynamic_cast<QgsGrassMapcalcConnector *>( *it );

for ( int i = 0; i < 2; i++ )
{
QPoint p = con->point( i );
Expand Down Expand Up @@ -1162,10 +1157,8 @@ void QgsGrassMapcalc::save()
{
--it;

if ( typeid( **it ) == typeid( QgsGrassMapcalcObject ) )
if ( QgsGrassMapcalcObject *obj = dynamic_cast<QgsGrassMapcalcObject *>( *it ) )
{
QgsGrassMapcalcObject *obj = dynamic_cast<QgsGrassMapcalcObject *>( *it );

QString type;
if ( obj->type() == QgsGrassMapcalcObject::Map )
{
Expand Down Expand Up @@ -1212,10 +1205,8 @@ void QgsGrassMapcalc::save()
}
stream << "/>\n";
}
else if ( typeid( **it ) == typeid( QgsGrassMapcalcConnector ) )
else if ( QgsGrassMapcalcConnector *con = dynamic_cast<QgsGrassMapcalcConnector *>( *it ) )
{
QgsGrassMapcalcConnector *con = dynamic_cast<QgsGrassMapcalcConnector *>( *it );

stream << " <connector id=\"" + QString::number( con->id() )
+ "\">\n";

Expand Down Expand Up @@ -1914,7 +1905,9 @@ QString QgsGrassMapcalcObject::expression()

/************************* CONNECTOR **********************************/
QgsGrassMapcalcConnector::QgsGrassMapcalcConnector( QGraphicsScene *canvas )
: QGraphicsLineItem(), QgsGrassMapcalcItem()
: QGraphicsLineItem()
, QgsGrassMapcalcItem()
, mSelectedEnd( -1 )
{
QgsDebugMsg( "entered." );

Expand Down Expand Up @@ -2042,11 +2035,8 @@ bool QgsGrassMapcalcConnector::tryConnectEnd( int end )
{
--it;

if ( typeid( **it ) == typeid( QgsGrassMapcalcObject ) )
{
object = dynamic_cast<QgsGrassMapcalcObject *>( *it );
if (( object = dynamic_cast<QgsGrassMapcalcObject *>( *it ) ) )
break;
}
}

// try to connect
Expand Down Expand Up @@ -2117,10 +2107,13 @@ QgsGrassMapcalcObject *QgsGrassMapcalcConnector::object( int end )
/************************* FUNCTION *****************************/
QgsGrassMapcalcFunction::QgsGrassMapcalcFunction( int type, QString name,
int count, QString description, QString label, QString labels,
bool drawLabel ) :
mName( name ), mType( type ), mInputCount( count ),
mLabel( label ), mDescription( description ),
mDrawLabel( drawLabel )
bool drawLabel )
: mName( name )
, mType( type )
, mInputCount( count )
, mLabel( label )
, mDescription( description )
, mDrawLabel( drawLabel )
{
if ( mLabel.isEmpty() )
mLabel = mName;
Expand All @@ -2131,6 +2124,17 @@ QgsGrassMapcalcFunction::QgsGrassMapcalcFunction( int type, QString name,
}
}

QgsGrassMapcalcFunction::QgsGrassMapcalcFunction()
: mType( 0 )
, mInputCount( 0 )
, mDrawLabel( false )
{
}

QgsGrassMapcalcFunction::~QgsGrassMapcalcFunction()
{
}

/******************** CANVAS VIEW ******************************/

QgsGrassMapcalcView::QgsGrassMapcalcView( QgsGrassMapcalc * mapcalc,
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/grass/qgsgrassmapcalc.h
Expand Up @@ -219,11 +219,11 @@ class QgsGrassMapcalcFunction
Function
};

QgsGrassMapcalcFunction() {};
QgsGrassMapcalcFunction();
QgsGrassMapcalcFunction( int type, QString name, int count = 2,
QString description = "", QString label = "",
QString labels = "", bool drawLabel = true );
~QgsGrassMapcalcFunction() {};
~QgsGrassMapcalcFunction();

QString name() { return mName; }
int type() { return mType; }
Expand Down
24 changes: 20 additions & 4 deletions src/plugins/grass/qgsgrassmodule.cpp
Expand Up @@ -149,8 +149,11 @@ QStringList QgsGrassModule::execArguments( QString module )
}

QgsGrassModule::QgsGrassModule( QgsGrassTools *tools, QString moduleName, QgisInterface *iface,
QString path, bool direct, QWidget * parent, Qt::WindowFlags f )
: QgsGrassModuleBase(), mSuccess( false ), mDirect( direct )
QString path, bool direct, QWidget *parent, Qt::WindowFlags f )
: QgsGrassModuleBase()
, mOptions( 0 )
, mSuccess( false )
, mDirect( direct )
{
Q_UNUSED( f );
QgsDebugMsg( "called" );
Expand Down Expand Up @@ -2033,8 +2036,18 @@ void QgsGrassModule::setDirectLibraryPath( QProcessEnvironment & environment )
QgsGrassModuleOption::QgsGrassModuleOption( QgsGrassModule *module, QString key,
QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode,
bool direct, QWidget * parent )
: QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, direct, parent ),
mControlType( NoControl ), mValueType( String ), mOutputType( None ), mHaveLimits( false ), mIsOutput( false )
: QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, direct, parent )
, mControlType( NoControl )
, mValueType( String )
, mOutputType( None )
, mHaveLimits( false )
, mMin( INT_MAX )
, mMax( INT_MIN )
, mComboBox( 0 )
, mIsOutput( false )
, mValidator( 0 )
, mLayout( 0 )
, mUsesRegion( false )
{
QgsDebugMsg( "called." );
setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum );
Expand Down Expand Up @@ -2540,11 +2553,14 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module,
QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode,
bool direct, QWidget * parent )
: QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, direct, parent )
, mType( QgsGrassModuleInput::Vector )
, mModuleStandardOptions( options )
, mGeometryTypeOption( "" )
, mVectorLayerOption( "" )
, mLayerComboBox( 0 )
, mRegionButton( 0 )
, mUpdate( false )
, mUsesRegion( false )
, mRequired( false )
{
QgsDebugMsg( "called." );
Expand Down

0 comments on commit b67daf0

Please sign in to comment.