Skip to content
Permalink
Browse files

more coverity fixes

  • Loading branch information
jef-n committed Feb 7, 2015
1 parent e3d5a05 commit a3668f585300638d32e927221ced711699051a12
Showing with 305 additions and 601 deletions.
  1. +1 −0 src/analysis/raster/qgsrastercalcnode.cpp
  2. +4 −4 src/analysis/vector/qgsoverlayanalyzer.cpp
  3. +4 −3 src/app/composer/qgscomposerlegendwidget.cpp
  4. +30 −21 src/app/ogr/qgsvectorlayersaveasdialog.cpp
  5. +2 −2 src/app/pluginmanager/qgspluginmanager.cpp
  6. +6 −3 src/app/qgisapp.cpp
  7. +3 −0 src/app/qgsaddattrdialog.cpp
  8. +4 −1 src/app/qgsapplayertreeviewmenuprovider.cpp
  9. +20 −13 src/app/qgslabelpropertydialog.cpp
  10. +6 −3 src/app/qgsvectorlayerproperties.cpp
  11. +4 −4 src/core/composer/qgscomposition.cpp
  12. +5 −1 src/core/composer/qgslegendmodel.cpp
  13. +1 −1 src/core/pal/problem.cpp
  14. +1 −0 src/core/qgsgml.cpp
  15. +4 −1 src/core/qgsmaplayer.cpp
  16. +5 −7 src/core/qgsvectorfilewriter.cpp
  17. +13 −4 src/core/qgsvectorlayer.cpp
  18. +2 −2 src/core/raster/qgsrasterfilewriter.cpp
  19. +11 −8 src/core/raster/qgsrasterprojector.cpp
  20. +5 −3 src/core/symbology-ng/qgscategorizedsymbolrendererv2.cpp
  21. +4 −2 src/core/symbology-ng/qgscptcityarchive.cpp
  22. +2 −2 src/core/symbology-ng/qgsvectorfieldsymbollayer.cpp
  23. +9 −6 src/gui/layertree/qgslayertreeviewdefaultactions.cpp
  24. +6 −2 src/gui/qgsmaptoolidentify.cpp
  25. +5 −0 src/gui/qgsrelationeditorwidget.cpp
  26. +1 −1 src/gui/symbology-ng/qgscptcitycolorrampv2dialog.cpp
  27. +6 −7 src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp
  28. +1 −1 src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.cpp
  29. +6 −7 src/plugins/topology/topolTest.cpp
  30. +1 −1 src/providers/spatialite/qgsspatialitedataitems.cpp
  31. +2 −1 src/providers/wms/qgswmssourceselect.cpp
  32. +1 −2 tests/src/core/testqgsgeometryimport.cpp
  33. +4 −5 tests/src/core/testqgsmaplayerstylemanager.cpp
  34. +125 −482 tests/src/core/testqgsvectorlayer.cpp
  35. +1 −1 tests/src/core/testziplayer.cpp
@@ -153,6 +153,7 @@ bool QgsRasterCalcNode::calculate( QMap<QString, QgsRasterMatrix*>& rasterData,
break;
case opATAN:
leftMatrix.atangens();
break;
case opSIGN:
leftMatrix.changeSign();
break;
@@ -31,14 +31,14 @@ bool QgsOverlayAnalyzer::intersection( QgsVectorLayer* layerA, QgsVectorLayer* l
const QString& shapefileName, bool onlySelectedFeatures,
QProgressDialog* p )
{
if ( !layerA && !layerB )
if ( !layerA || !layerB )
{
return false;
}

QgsVectorDataProvider* dpA = layerA->dataProvider();
QgsVectorDataProvider* dpB = layerB->dataProvider();
if ( !dpA && !dpB )
QgsVectorDataProvider *dpA = layerA->dataProvider();
QgsVectorDataProvider *dpB = layerB->dataProvider();
if ( !dpA || !dpB )
{
return false;
}
@@ -87,7 +87,9 @@ class QgsComposerLegendMenuProvider : public QObject, public QgsLayerTreeViewMen



QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend* legend ): QgsComposerItemBaseWidget( 0, legend ), mLegend( legend )
QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend* legend )
: QgsComposerItemBaseWidget( 0, legend )
, mLegend( legend )
{
setupUi( this );

@@ -113,10 +115,9 @@ QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend* legend ): Q
if ( legend )
{
connect( legend, SIGNAL( itemChanged() ), this, SLOT( setGuiElements() ) );
mWrapCharLineEdit->setText( legend->wrapChar() );
}

mWrapCharLineEdit->setText( legend->wrapChar() );

setGuiElements();

connect( mItemTreeView->selectionModel(), SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
@@ -115,39 +115,48 @@ QList<QPair<QLabel*, QWidget*> > QgsVectorLayerSaveAsDialog::createControls( con
{
case QgsVectorFileWriter::Int:
{
QgsVectorFileWriter::IntOption* opt = dynamic_cast<QgsVectorFileWriter::IntOption*>( option );
QSpinBox* sb = new QSpinBox();
sb->setObjectName( it.key() );
sb->setValue( opt->defaultValue );
control = sb;
QgsVectorFileWriter::IntOption *opt = dynamic_cast<QgsVectorFileWriter::IntOption*>( option );
if ( opt )
{
QSpinBox *sb = new QSpinBox();
sb->setObjectName( it.key() );
sb->setValue( opt->defaultValue );
control = sb;
}
break;
}

case QgsVectorFileWriter::Set:
{
QgsVectorFileWriter::SetOption* opt = dynamic_cast<QgsVectorFileWriter::SetOption*>( option );
QComboBox* cb = new QComboBox();
cb->setObjectName( it.key() );
Q_FOREACH ( const QString& val, opt->values )
QgsVectorFileWriter::SetOption *opt = dynamic_cast<QgsVectorFileWriter::SetOption*>( option );
if ( opt )
{
cb->addItem( val, val );
QComboBox* cb = new QComboBox();
cb->setObjectName( it.key() );
Q_FOREACH ( const QString& val, opt->values )
{
cb->addItem( val, val );
}
if ( opt->allowNone )
cb->addItem( tr( "<Default>" ), QVariant( QVariant::String ) );
int idx = cb->findText( opt->defaultValue );
if ( idx == -1 )
idx = cb->findData( QVariant( QVariant::String ) );
cb->setCurrentIndex( idx );
control = cb;
}
if ( opt->allowNone )
cb->addItem( tr( "<Default>" ), QVariant( QVariant::String ) );
int idx = cb->findText( opt->defaultValue );
if ( idx == -1 )
idx = cb->findData( QVariant( QVariant::String ) );
cb->setCurrentIndex( idx );
control = cb;
break;
}

case QgsVectorFileWriter::String:
{
QgsVectorFileWriter::StringOption* opt = dynamic_cast<QgsVectorFileWriter::StringOption*>( option );
QLineEdit* le = new QLineEdit( opt->defaultValue );
le->setObjectName( it.key() );
control = le;
QgsVectorFileWriter::StringOption *opt = dynamic_cast<QgsVectorFileWriter::StringOption*>( option );
if ( opt )
{
QLineEdit* le = new QLineEdit( opt->defaultValue );
le->setObjectName( it.key() );
control = le;
}
break;
}

@@ -1226,8 +1226,8 @@ void QgsPluginManager::on_buttonUninstall_clicked()

void QgsPluginManager::on_treeRepositories_itemSelectionChanged()
{
buttonEditRep->setEnabled( ! treeRepositories -> selectedItems().isEmpty() );
buttonDeleteRep->setEnabled( ! treeRepositories -> selectedItems().isEmpty() );
buttonEditRep->setEnabled( ! treeRepositories->selectedItems().isEmpty() );
buttonDeleteRep->setEnabled( ! treeRepositories->selectedItems().isEmpty() );
}


@@ -713,7 +713,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
QgsPythonRunner::run( "import pyplugin_installer" );
QgsPythonRunner::run( "pyplugin_installer.initPluginInstaller()" );
// enable Python in the Plugin Manager and pass the PythonUtils to it
mPluginManager -> setPythonUtils( mPythonUtils );
mPluginManager->setPythonUtils( mPythonUtils );
}
else
{
@@ -2988,13 +2988,16 @@ bool QgisApp::askUserForZipItemLayers( QString path )
foreach ( QgsDataItem* item, childItems )
{
QgsLayerItem *layerItem = dynamic_cast<QgsLayerItem *>( item );
if ( !layerItem )
continue;

QgsDebugMsg( QString( "item path=%1 provider=%2" ).arg( item->path() ).arg( layerItem->providerKey() ) );
if ( layerItem && layerItem->providerKey() == "gdal" )
if ( layerItem->providerKey() == "gdal" )
{
if ( addRasterLayer( item->path(), QFileInfo( item->name() ).completeBaseName() ) )
ok = true;
}
else if ( layerItem && layerItem->providerKey() == "ogr" )
else if ( layerItem->providerKey() == "ogr" )
{
if ( addVectorLayers( QStringList( item->path() ), "System", "file" ) )
ok = true;
@@ -28,6 +28,9 @@ QgsAddAttrDialog::QgsAddAttrDialog( QgsVectorLayer *vlayer, QWidget *parent, Qt:
{
setupUi( this );

if ( !vlayer )
return;

//fill data types into the combo box
const QList< QgsVectorDataProvider::NativeType > &typelist = vlayer->dataProvider()->nativeTypes();

@@ -217,8 +217,11 @@ bool QgsAppLayerTreeViewMenuProvider::removeLegendLayerAction( QAction* action )

void QgsAppLayerTreeViewMenuProvider::addLegendLayerActionForLayer( QAction* action, QgsMapLayer* layer )
{
if ( !action || !layer )
return;

legendLayerActions( layer->type() );
if ( !action || !layer || ! mLegendLayerActionMap.contains( layer->type() ) )
if ( !mLegendLayerActionMap.contains( layer->type() ) )
return;

QMap< QgsMapLayer::LayerType, QList< LegendLayerAction > >::iterator it
@@ -80,20 +80,27 @@ void QgsLabelPropertyDialog::init( const QString& layerId, int featureId, const
if ( !labelFieldName.isEmpty() )
{
mCurLabelField = vlayer->fieldNameIndex( labelFieldName );
mLabelTextLineEdit->setText( attributeValues[mCurLabelField].toString() );
const QgsFields& layerFields = vlayer->pendingFields();
switch ( layerFields[mCurLabelField].type() )
if ( mCurLabelField >= 0 )
{
case QVariant::Double:
mLabelTextLineEdit->setValidator( new QDoubleValidator( this ) );
break;
case QVariant::Int:
case QVariant::UInt:
case QVariant::LongLong:
mLabelTextLineEdit->setValidator( new QIntValidator( this ) );
break;
default:
break;
mLabelTextLineEdit->setText( attributeValues[mCurLabelField].toString() );
const QgsFields& layerFields = vlayer->pendingFields();
switch ( layerFields[mCurLabelField].type() )
{
case QVariant::Double:
mLabelTextLineEdit->setValidator( new QDoubleValidator( this ) );
break;
case QVariant::Int:
case QVariant::UInt:
case QVariant::LongLong:
mLabelTextLineEdit->setValidator( new QIntValidator( this ) );
break;
default:
break;
}
}
else
{
mLabelTextLineEdit->setEnabled( false );
}
}
}
@@ -293,9 +293,12 @@ QgsVectorLayerProperties::~QgsVectorLayerProperties()

void QgsVectorLayerProperties::toggleEditing()
{
if ( !layer )
return;

emit toggleEditing( layer );

pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
pbnQueryBuilder->setEnabled( layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
!layer->isEditable() && layer->vectorJoins().size() < 1 );
if ( layer->isEditable() )
{
@@ -381,7 +384,7 @@ void QgsVectorLayerProperties::syncToLayer( void )
// on the builder. If the ability to enter a query directly into the box is required,
// a mechanism to check it must be implemented.
txtSubsetSQL->setEnabled( false );
pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
pbnQueryBuilder->setEnabled( layer->dataProvider() && layer->dataProvider()->supportsSubsetString() &&
!layer->isEditable() && layer->vectorJoins().size() < 1 );
if ( layer->isEditable() )
{
@@ -396,7 +399,7 @@ void QgsVectorLayerProperties::syncToLayer( void )
fieldComboBox->addItem( myFields[idx].name() );
}

setDisplayField( layer-> displayField() );
setDisplayField( layer->displayField() );

// set up the scale based layer visibility stuff....
mScaleRangeWidget->setScaleRange( 1.0 / layer->maximumScale(), 1.0 / layer->minimumScale() ); // caution: layer uses scale denoms, widget uses true scales
@@ -1069,11 +1069,11 @@ void QgsComposition::addItemsFromXML( const QDomElement& elem, const QDomDocumen

//since we are pasting items, clear the existing selection
setAllUnselected();
}

if ( pasteInPlace )
{
pasteInPlacePt = new QPointF( 0, pageNumberAt( *pos ) * ( mPageHeight + mSpaceBetweenPages ) );
if ( pasteInPlace )
{
pasteInPlacePt = new QPointF( 0, pageNumberAt( *pos ) * ( mPageHeight + mSpaceBetweenPages ) );
}
}
QDomNodeList composerLabelList = elem.elementsByTagName( "ComposerLabel" );
for ( int i = 0; i < composerLabelList.size(); ++i )
@@ -662,7 +662,6 @@ bool QgsLegendModel::readXML( const QDomElement& legendModelElem, const QDomDocu

QDomNodeList topLevelItemList = legendModelElem.childNodes();
QDomElement currentElem;
QgsComposerLegendItem* currentItem = 0;

int nTopLevelItems = topLevelItemList.size();
for ( int i = 0; i < nTopLevelItems; ++i )
@@ -674,6 +673,7 @@ bool QgsLegendModel::readXML( const QDomElement& legendModelElem, const QDomDocu
}

//toplevel items can be groups or layers
QgsComposerLegendItem* currentItem = 0;
if ( currentElem.tagName() == "LayerItem" )
{
currentItem = new QgsComposerLayerItem();
@@ -682,6 +682,10 @@ bool QgsLegendModel::readXML( const QDomElement& legendModelElem, const QDomDocu
{
currentItem = new QgsComposerGroupItem();
}

if ( !currentItem )
continue;

currentItem->readXML( currentElem, mHasTopLevelWindow );

QList<QStandardItem *> itemsList;
@@ -2352,7 +2352,7 @@ namespace pal
std::cout << "new_best" << std::endl;
#endif
best_cost = cur_cost;
memcpy( best_sol, sol, sizeof( int ) *subSize );
memcpy( best_sol, sol, sizeof( int ) * subSize );

stop_it = ( it + itwimp > maxit ? maxit : it + itwimp );
}
@@ -431,6 +431,7 @@ void QgsGml::endElement( const XML_Char* el )
else
{
QgsDebugMsg( "No wkb fragments" );
delete [] wkb;
}
}
}
@@ -641,7 +641,7 @@ QList<QgsMapLayer*> QgsMapLayer::fromLayerDefinition( QDomDocument& document )

QString type = layerElem.attribute( "type" );
QgsDebugMsg( type );
QgsMapLayer *layer = NULL;
QgsMapLayer *layer = 0;

if ( type == "vector" )
{
@@ -657,6 +657,9 @@ QList<QgsMapLayer*> QgsMapLayer::fromLayerDefinition( QDomDocument& document )
layer = QgsPluginLayerRegistry::instance()->createLayer( typeName );
}

if ( !layer )
continue;

bool ok = layer->readLayerXML( layerElem );
if ( ok )
layers << layer;
@@ -2447,14 +2447,12 @@ QgsVectorFileWriter::WriterError QgsVectorFileWriter::exportFeaturesSymbolLevels
const QgsCoordinateTransform* ct, QString* errorMessage )
{
if ( !layer )
{
//return error
}
QgsFeatureRendererV2* renderer = layer->rendererV2();
return ErrInvalidLayer;

QgsFeatureRendererV2 *renderer = layer->rendererV2();
if ( !renderer )
{
//return error
}
return ErrInvalidLayer;

QHash< QgsSymbolV2*, QList<QgsFeature> > features;

//unit type
@@ -2907,17 +2907,20 @@ void QgsVectorLayer::uniqueValues( int index, QList<QVariant> &uniqueValues, int
const QgsVectorJoinInfo* join = mJoinBuffer->joinForFieldIndex( index, mUpdatedFields, sourceLayerIndex );
Q_ASSERT( join );

QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( join->joinLayerId ) );
Q_ASSERT( vl );
QgsVectorLayer *vl = dynamic_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( join->joinLayerId ) );

return vl->dataProvider()->uniqueValues( sourceLayerIndex, uniqueValues, limit );
if ( vl )
vl->dataProvider()->uniqueValues( sourceLayerIndex, uniqueValues, limit );

return;
}
else if ( origin == QgsFields::OriginEdit || origin == QgsFields::OriginExpression )
{
// the layer is editable, but in certain cases it can still be avoided going through all features
if ( origin == QgsFields::OriginEdit && mEditBuffer->mDeletedFeatureIds.isEmpty() && mEditBuffer->mAddedFeatures.isEmpty() && !mEditBuffer->mDeletedAttributeIds.contains( index ) && mEditBuffer->mChangedAttributeValues.isEmpty() )
{
return mDataProvider->uniqueValues( index, uniqueValues, limit );
mDataProvider->uniqueValues( index, uniqueValues, limit );
return;
}

// we need to go through each feature
@@ -3608,10 +3611,16 @@ void QgsVectorLayer::onRelationsLoaded()
if ( elem->type() == QgsAttributeEditorElement::AeTypeContainer )
{
QgsAttributeEditorContainer* cont = dynamic_cast< QgsAttributeEditorContainer* >( elem );
if ( !cont )
continue;

QList<QgsAttributeEditorElement*> relations = cont->findElements( QgsAttributeEditorElement::AeTypeRelation );
Q_FOREACH ( QgsAttributeEditorElement* relElem, relations )
{
QgsAttributeEditorRelation* rel = dynamic_cast< QgsAttributeEditorRelation* >( relElem );
if ( !rel )
continue;

rel->init( QgsProject::instance()->relationManager() );
}
}

0 comments on commit a3668f5

Please sign in to comment.
You can’t perform that action at this time.