more coverity fixes

This commit is contained in:
Juergen E. Fischer 2015-02-07 02:31:42 +01:00
parent e3d5a0549c
commit a3668f5853
35 changed files with 306 additions and 602 deletions

View File

@ -153,6 +153,7 @@ bool QgsRasterCalcNode::calculate( QMap<QString, QgsRasterMatrix*>& rasterData,
break;
case opATAN:
leftMatrix.atangens();
break;
case opSIGN:
leftMatrix.changeSign();
break;

View File

@ -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;
}

View File

@ -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 & ) ),

View File

@ -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;
}

View File

@ -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() );
}

View File

@ -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;

View File

@ -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();

View File

@ -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

View File

@ -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 );
}
}
}

View File

@ -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

View File

@ -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 )

View File

@ -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;

View File

@ -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 );
}

View File

@ -431,6 +431,7 @@ void QgsGml::endElement( const XML_Char* el )
else
{
QgsDebugMsg( "No wkb fragments" );
delete [] wkb;
}
}
}

View File

@ -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;

View File

@ -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

View File

@ -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() );
}
}

View File

@ -321,7 +321,7 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeDataRaster(
QgsDebugMsg( "Entered" );
const QgsRasterInterface* iface = iter->input();
const QgsRasterDataProvider* srcProvider = dynamic_cast<const QgsRasterDataProvider*>( iface->srcInput() );
const QgsRasterDataProvider *srcProvider = dynamic_cast<const QgsRasterDataProvider*>( iface->srcInput() );
int nBands = iface->bandCount();
QgsDebugMsg( QString( "nBands = %1" ).arg( nBands ) );
@ -405,7 +405,7 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeDataRaster(
QList<QgsRasterBlock*> destBlockList;
for ( int i = 1; i <= nBands; ++i )
{
if ( srcProvider->dataType( i ) == destDataType )
if ( srcProvider && srcProvider->dataType( i ) == destDataType )
{
destBlockList.push_back( blockList[i-1] );
}

View File

@ -174,15 +174,18 @@ void QgsRasterProjector::calc()
if ( mInput )
{
QgsRasterDataProvider *provider = dynamic_cast<QgsRasterDataProvider*>( mInput->srcInput() );
if ( provider && ( provider->capabilities() & QgsRasterDataProvider::Size ) )
if ( provider )
{
mMaxSrcXRes = provider->extent().width() / provider->xSize();
mMaxSrcYRes = provider->extent().height() / provider->ySize();
}
// Get source extent
if ( mExtent.isEmpty() )
{
mExtent = provider->extent();
if ( provider->capabilities() & QgsRasterDataProvider::Size )
{
mMaxSrcXRes = provider->extent().width() / provider->xSize();
mMaxSrcYRes = provider->extent().height() / provider->ySize();
}
// Get source extent
if ( mExtent.isEmpty() )
{
mExtent = provider->extent();
}
}
}

View File

@ -806,12 +806,14 @@ QgsCategorizedSymbolRendererV2* QgsCategorizedSymbolRendererV2::convertFromRende
if ( renderer->type() == "pointDisplacement" )
{
const QgsPointDisplacementRenderer* pointDisplacementRenderer = dynamic_cast<const QgsPointDisplacementRenderer*>( renderer );
return convertFromRenderer( pointDisplacementRenderer->embeddedRenderer() );
if ( pointDisplacementRenderer )
return convertFromRenderer( pointDisplacementRenderer->embeddedRenderer() );
}
if ( renderer->type() == "invertedPolygonRenderer" )
{
const QgsInvertedPolygonRenderer* invertedPolygonRenderer = dynamic_cast<const QgsInvertedPolygonRenderer*>( renderer );
return convertFromRenderer( invertedPolygonRenderer->embeddedRenderer() );
if ( invertedPolygonRenderer )
return convertFromRenderer( invertedPolygonRenderer->embeddedRenderer() );
}
// If not one of the specifically handled renderers, then just grab the symbol from the renderer
@ -823,6 +825,6 @@ QgsCategorizedSymbolRendererV2* QgsCategorizedSymbolRendererV2::convertFromRende
{
r->setSourceSymbol( symbols.at( 0 )->clone() );
}
return r;
return r;
}

View File

@ -794,8 +794,10 @@ bool QgsCptCityColorRampItem::equal( const QgsCptCityDataItem *other )
}
//const QgsCptCityColorRampItem *o = qobject_cast<const QgsCptCityColorRampItem *> ( other );
const QgsCptCityColorRampItem *o = dynamic_cast<const QgsCptCityColorRampItem *>( other );
return ( mPath == o->mPath && mName == o->mName &&
ramp().variantName() == o->ramp().variantName() );
return o &&
mPath == o->mPath &&
mName == o->mName &&
ramp().variantName() == o->ramp().variantName();
}
QIcon QgsCptCityColorRampItem::icon()

View File

@ -164,12 +164,12 @@ void QgsVectorFieldSymbolLayer::renderPoint( const QPointF& point, QgsSymbolV2Re
double yComponent = 0;
double xVal = 0;
if ( mXIndex != -1 )
if ( f && mXIndex != -1 )
{
xVal = f->attribute( mXIndex ).toDouble();
}
double yVal = 0;
if ( mYIndex != -1 )
if ( f && mYIndex != -1 )
{
yVal = f->attribute( mYIndex ).toDouble();
}

View File

@ -204,13 +204,16 @@ void QgsLayerTreeViewDefaultActions::zoomToLayers( QgsMapCanvas* canvas, const Q
QgsRectangle layerExtent = layer->extent();
QgsVectorLayer *vLayer = qobject_cast<QgsVectorLayer*>( layer );
if ( vLayer && vLayer->geometryType() == QGis::NoGeometry )
continue;
if ( layerExtent.isEmpty() && layer->type() == QgsMapLayer::VectorLayer )
if ( vLayer )
{
qobject_cast<QgsVectorLayer*>( layer )->updateExtents();
layerExtent = vLayer->extent();
if ( vLayer->geometryType() == QGis::NoGeometry )
continue;
if ( layerExtent.isEmpty() )
{
vLayer->updateExtents();
layerExtent = vLayer->extent();
}
}
if ( layerExtent.isNull() )

View File

@ -357,8 +357,11 @@ bool QgsMapToolIdentify::identifyRasterLayer( QList<IdentifyResult> *results, Qg
return false;
QgsRasterDataProvider *dprovider = layer->dataProvider();
if ( !dprovider )
return false;
int capabilities = dprovider->capabilities();
if ( !dprovider || !( capabilities & QgsRasterDataProvider::Identify ) )
if ( !( capabilities & QgsRasterDataProvider::Identify ) )
return false;
QgsPoint pointInCanvasCrs = point;
@ -374,7 +377,8 @@ bool QgsMapToolIdentify::identifyRasterLayer( QList<IdentifyResult> *results, Qg
}
QgsDebugMsg( QString( "point = %1 %2" ).arg( point.x() ).arg( point.y() ) );
if ( !layer->extent().contains( point ) ) return false;
if ( !layer->extent().contains( point ) )
return false;
QMap< QString, QString > attributes, derivedAttributes;

View File

@ -246,6 +246,11 @@ void QgsRelationEditorWidget::unlinkFeature()
Q_FOREACH ( const QgsRelation::FieldPair fieldPair, mRelation.fieldPairs() )
{
int idx = mRelation.referencingLayer()->fieldNameIndex( fieldPair.referencingField() );
if ( idx < 0 )
{
QgsDebugMsg( QString( "referencing field %1 not found" ).arg( fieldPair.referencingField() ) );
return;
}
QgsField fld = mRelation.referencingLayer()->pendingFields().at( idx );
keyFields.insert( idx, fld );
}

View File

@ -314,7 +314,7 @@ void QgsCptCityColorRampV2Dialog::on_mListWidget_itemClicked( QListWidgetItem *
}
else
{
QgsDebugMsg( QString( "item %1 has invalid type %2" ).arg( rampItem->path() ).arg(( int )rampItem->type() ) );
QgsDebugMsg( "invalid item" );
}
}

View File

@ -548,9 +548,8 @@ void QgsGraduatedSymbolRendererV2Widget::classifyGraduated()
int nclasses = spinGraduatedClasses->value();
QgsVectorColorRampV2* ramp = cboGraduatedColorRamp->currentColorRamp();
if ( ramp == NULL )
QSharedPointer<QgsVectorColorRampV2> ramp( cboGraduatedColorRamp->currentColorRamp() );
if ( !ramp )
{
if ( cboGraduatedColorRamp->count() == 0 )
QMessageBox::critical( this, tr( "Error" ), tr( "There are no available color ramps. You can add them in Style Manager." ) );
@ -571,13 +570,12 @@ void QgsGraduatedSymbolRendererV2Widget::classifyGraduated()
else // default should be quantile for now
mode = QgsGraduatedSymbolRendererV2::Quantile;
// Jenks is n^2 complexity, warn for big dataset (more than 50k records)
// and give the user the chance to cancel
if ( QgsGraduatedSymbolRendererV2::Jenks == mode
&& mLayer->featureCount() > 50000 )
if ( QgsGraduatedSymbolRendererV2::Jenks == mode && mLayer->featureCount() > 50000 )
{
if ( QMessageBox::Cancel == QMessageBox::question( this, tr( "Warning" ), tr( "Natural break classification (Jenks) is O(n2) complexity, your classification may take a long time.\nPress cancel to abort breaks calculation or OK to continue." ), QMessageBox::Cancel, QMessageBox::Ok ) ) return;
if ( QMessageBox::Cancel == QMessageBox::question( this, tr( "Warning" ), tr( "Natural break classification (Jenks) is O(n2) complexity, your classification may take a long time.\nPress cancel to abort breaks calculation or OK to continue." ), QMessageBox::Cancel, QMessageBox::Ok ) )
return;
}
// create and set new renderer
@ -585,6 +583,7 @@ void QgsGraduatedSymbolRendererV2Widget::classifyGraduated()
mRenderer->setClassAttribute( attrName );
mRenderer->setMode( mode );
mRenderer->setSourceColorRamp( ramp->clone() );
QApplication::setOverrideCursor( Qt::WaitCursor );
mRenderer->updateClasses( mLayer, mode, nclasses );
mRenderer->calculateLabelPrecision();

View File

@ -505,7 +505,7 @@ bool DL_Dxf::processDXFGroup( DL_CreationInterface* creationInterface,
color = toInt( values[62], 256 );
char linetype[DL_DXF_MAXLINE+1];
strcpy( linetype, toString( values[6], "BYLAYER" ) );
strncpy( linetype, toString( values[6], "BYLAYER" ), DL_DXF_MAXLINE );
attrib = DL_Attributes( values[8], // layer
color, // color

View File

@ -164,6 +164,12 @@ ErrorList topolTest::checkCloseFeature( double tolerance, QgsVectorLayer* layer1
break;
QgsGeometry* g1 = it->feature.geometry();
if ( !g1 || !g1->asGeos() )
{
badG1 = true;
continue;
}
QgsRectangle bb = g1->boundingBox();
// increase bounding box by tolerance
@ -190,13 +196,6 @@ ErrorList topolTest::checkCloseFeature( double tolerance, QgsVectorLayer* layer1
continue;
}
if ( !g1 || !g1->asGeos() )
{
badG1 = true;
continue;
}
if ( g1->distance( *g2 ) < tolerance )
{
QgsRectangle r = g2->boundingBox();

View File

@ -143,7 +143,7 @@ bool QgsSLConnectionItem::equal( const QgsDataItem *other )
return false;
}
const QgsSLConnectionItem *o = dynamic_cast<const QgsSLConnectionItem *>( other );
return ( mPath == o->mPath && mName == o->mName );
return o && mPath == o->mPath && mName == o->mName;
}
QList<QAction*> QgsSLConnectionItem::actions()

View File

@ -523,7 +523,8 @@ void QgsWMSSourceSelect::addClicked()
}
}
Q_ASSERT( layer );
if ( !layer )
return;
if ( !layer->dimensions.isEmpty() )
{

View File

@ -147,12 +147,11 @@ void TestQgsGeometryImport::linestringWkt()
QFETCH( QString, wktString );
QFETCH( QVariantList, line );
QgsGeometry* geom = QgsGeometry::fromWkt( wktString );
QSharedPointer<QgsGeometry> geom( QgsGeometry::fromWkt( wktString ) );
QCOMPARE( geom->wkbType(), QGis::WKBLineString );
QgsPolyline polyLine = geom->asPolyline();
QVERIFY( compareLineStrings( polyLine, line ) );
delete geom;
}
void TestQgsGeometryImport::linestringWkb_data()

View File

@ -60,14 +60,11 @@ void TestQgsMapLayerStyleManager::testDefault()
void TestQgsMapLayerStyleManager::testStyle()
{
QgsLineSymbolV2* sym1 = new QgsLineSymbolV2();
sym1->setColor( Qt::magenta );
QgsLineSymbolV2* sym2 = new QgsLineSymbolV2();
sym2->setColor( Qt::red );
QgsMapLayerStyle st;
QCOMPARE( st.isValid(), false );
QgsLineSymbolV2* sym1 = new QgsLineSymbolV2();
sym1->setColor( Qt::magenta );
mVL->setRendererV2( new QgsSingleSymbolRendererV2( sym1 ) );
QgsMapLayerStyle st1;
@ -76,6 +73,8 @@ void TestQgsMapLayerStyleManager::testStyle()
qDebug( "CNT-1: %s", st1.xmlData().toAscii().data() );
QgsLineSymbolV2* sym2 = new QgsLineSymbolV2();
sym2->setColor( Qt::red );
mVL->setRendererV2( new QgsSingleSymbolRendererV2( sym2 ) );
QgsMapLayerStyle st2;

View File

@ -166,8 +166,8 @@ class TestQgsVectorLayer : public QObject
QgsApplication::exitQgis();
}
void init() {};// will be called before each testfunction is executed.
void cleanup() {};// will be called after every testfunction.
void init() {} // will be called before each testfunction is executed.
void cleanup() {} // will be called after every testfunction.
void QgsVectorLayerNonSpatialIterator()
{
@ -182,428 +182,114 @@ class TestQgsVectorLayer : public QObject
myCount++;
}
QVERIFY( myCount == 3 );
};
}
void QgsVectorLayerstorageType() {}
void QgsVectorLayercapabilitiesString() {}
void QgsVectorLayerdataComment() {}
void QgsVectorLayerproviderType() {}
void QgsVectorLayersetDisplayField() {}
void QgsVectorLayerdrawLabels() {}
void QgsVectorLayerdrawLineString() {}
void QgsVectorLayerdrawPolygon() {}
void QgsVectorLayerdrawRendererV2() {}
void QgsVectorLayerdrawRendererV2Levels() {}
void QgsVectorLayerreload() {}
void QgsVectorLayerdraw() {}
void QgsVectorLayerdeleteCachedGeometries() {}
void QgsVectorLayerdrawVertexMarker() {}
void QgsVectorLayerselect() {}
void QgsVectorLayerinvertSelection() {}
void QgsVectorLayerinvertSelectionInRectangle() {}
void QgsVectorLayerremoveSelection() {}
void QgsVectorLayertriggerRepaint() {}
void QgsVectorLayerdataProvider() {}
void QgsVectorLayersetProviderEncoding() {}
void QgsVectorLayerrenderer() {}
void QgsVectorLayersetRenderer() {}
void QgsVectorLayergeometryType() {}
void QgsVectorLayerwkbType() {}
void QgsVectorLayerboundingBoxOfSelected() {}
void QgsVectorLayerfeatureCount() {}
void QgsVectorLayerupdateFeatureCount() {}
void QgsVectorLayerupdateExtents() {}
void QgsVectorLayersubsetString() {}
void QgsVectorLayersetSubsetString() {}
void QgsVectorLayerupdateFeatureAttributes() {}
void QgsVectorLayerupdateFeatureGeometry() {}
void QgsVectorLayernextFeature() {}
void QgsVectorLayerfeatureAtId() {}
void QgsVectorLayeraddFeature() {}
void QgsVectorLayerinsertVertex() {}
void QgsVectorLayermoveVertex() {}
void QgsVectorLayerdeleteVertex() {}
void QgsVectorLayerdeleteSelectedFeatures() {}
void QgsVectorLayeraddRing() {}
void QgsVectorLayeraddIsland() {}
void QgsVectorLayertranslateFeature() {}
void QgsVectorLayersplitFeatures() {}
void QgsVectorLayerremovePolygonIntersections() {}
void QgsVectorLayeraddTopologicalPoints() {}
void QgsVectorLayerlabel() {}
void QgsVectorLayerenableLabels() {}
void QgsVectorLayerhasLabelsEnabled() {}
void QgsVectorLayerstartEditing() {}
void QgsVectorLayerreadXml() {}
void QgsVectorLayersetDataProvider() {}
void QgsVectorLayerwriteXml() {}
void QgsVectorLayerreadSymbology() {}
void QgsVectorLayerwriteSymbology() {}
void QgsVectorLayerchangeGeometry() {}
void QgsVectorLayerchangeAttributeValue() {}
void QgsVectorLayeraddAttribute() {}
void QgsVectorLayeraddAttributeAlias() {}
void QgsVectorLayerattributeAlias() {}
void QgsVectorLayerattributeDisplayName() {}
void QgsVectorLayerdeleteAttribute() {}
void QgsVectorLayerdeleteFeature() {}
void QgsVectorLayerpendingFields() {}
void QgsVectorLayerpendingAllAttributesList() {}
void QgsVectorLayerpendingFeatureCount() {}
void QgsVectorLayercommitChanges() {}
void QgsVectorLayercommitErrors() {}
void QgsVectorLayerrollBack() {}
void QgsVectorLayersetSelectedFeatures() {}
void QgsVectorLayerselectedFeatureCount() {}
void QgsVectorLayerselectedFeaturesIds() {}
void QgsVectorLayerselectedFeatures() {}
void QgsVectorLayeraddFeatures() {}
void QgsVectorLayercopySymbologySettings() {}
void QgsVectorLayerhasCompatibleSymbology() {}
void QgsVectorLayersnapPoint() {}
void QgsVectorLayersnapWithContext() {}
void QgsVectorLayersnapToGeometry() {}
void QgsVectorLayerinsertSegmentVerticesForSnap() {}
void QgsVectorLayerboundingBoxFromPointList() {}
void QgsVectorLayercurrentVertexMarkerType() {}
void QgsVectorLayercurrentVertexMarkerSize() {}
void QgsVectorLayerdrawFeature() {}
void QgsVectorLayersetCoordinateSystem() {}
void QgsVectorLayertransformPoint() {}
void QgsVectorLayertransformPoints() {}
void QgsVectorLayerdisplayField() {}
void QgsVectorLayerisEditable() {}
void QgsVectorLayerisModified() {}
void QgsVectorLayersetModified() {}
void QgsVectorLayereditType() {}
void QgsVectorLayersetEditType() {}
void QgsVectorLayereditForm() {}
void QgsVectorLayersetEditForm() {}
void QgsVectorLayersetAnnotationForm() {}
void QgsVectorLayereditFormInit() {}
void QgsVectorLayersetEditFormInit() {}
void QgsVectorLayervalueMap() {}
void QgsVectorLayerrange() {}
void QgsVectorLayeraddOverlay() {}
void QgsVectorLayerremoveOverlay() {}
void QgsVectorLayervectorOverlays() {}
void QgsVectorLayerfindOverlayByType() {}
void QgsVectorLayerrendererV2() {}
void QgsVectorLayerstorageType()
{
};
void QgsVectorLayercapabilitiesString()
{
};
void QgsVectorLayerdataComment()
{
};
void QgsVectorLayerproviderType()
{
};
void QgsVectorLayersetDisplayField()
{
};
void QgsVectorLayerdrawLabels()
{
};
void QgsVectorLayerdrawLineString()
{
};
void QgsVectorLayerdrawPolygon()
{
};
void QgsVectorLayerdrawRendererV2()
{
};
void QgsVectorLayerdrawRendererV2Levels()
{
};
void QgsVectorLayerreload()
{
};
void QgsVectorLayerdraw()
{
};
void QgsVectorLayerdeleteCachedGeometries()
{
};
void QgsVectorLayerdrawVertexMarker()
{
};
void QgsVectorLayerselect()
{
};
void QgsVectorLayerinvertSelection()
{
};
void QgsVectorLayerinvertSelectionInRectangle()
{
};
void QgsVectorLayerremoveSelection()
{
};
void QgsVectorLayertriggerRepaint()
{
};
void QgsVectorLayerdataProvider()
{
};
void QgsVectorLayersetProviderEncoding()
{
};
void QgsVectorLayerrenderer()
{
};
void QgsVectorLayersetRenderer()
{
};
void QgsVectorLayergeometryType()
{
};
void QgsVectorLayerwkbType()
{
};
void QgsVectorLayerboundingBoxOfSelected()
{
};
void QgsVectorLayerfeatureCount()
{
};
void QgsVectorLayerupdateFeatureCount()
{
};
void QgsVectorLayerupdateExtents()
{
};
void QgsVectorLayersubsetString()
{
};
void QgsVectorLayersetSubsetString()
{
};
void QgsVectorLayerupdateFeatureAttributes()
{
};
void QgsVectorLayerupdateFeatureGeometry()
{
};
void QgsVectorLayernextFeature()
{
};
void QgsVectorLayerfeatureAtId()
{
};
void QgsVectorLayeraddFeature()
{
};
void QgsVectorLayerinsertVertex()
{
};
void QgsVectorLayermoveVertex()
{
};
void QgsVectorLayerdeleteVertex()
{
};
void QgsVectorLayerdeleteSelectedFeatures()
{
};
void QgsVectorLayeraddRing()
{
};
void QgsVectorLayeraddIsland()
{
};
void QgsVectorLayertranslateFeature()
{
};
void QgsVectorLayersplitFeatures()
{
};
void QgsVectorLayerremovePolygonIntersections()
{
};
void QgsVectorLayeraddTopologicalPoints()
{
};
void QgsVectorLayerlabel()
{
};
void QgsVectorLayerenableLabels()
{
};
void QgsVectorLayerhasLabelsEnabled()
{
};
void QgsVectorLayerstartEditing()
{
};
void QgsVectorLayerreadXml()
{
};
void QgsVectorLayersetDataProvider()
{
};
void QgsVectorLayerwriteXml()
{
};
void QgsVectorLayerreadSymbology()
{
};
void QgsVectorLayerwriteSymbology()
{
};
void QgsVectorLayerchangeGeometry()
{
};
void QgsVectorLayerchangeAttributeValue()
{
};
void QgsVectorLayeraddAttribute()
{
};
void QgsVectorLayeraddAttributeAlias()
{
};
void QgsVectorLayerattributeAlias()
{
};
void QgsVectorLayerattributeDisplayName()
{
};
void QgsVectorLayerdeleteAttribute()
{
};
void QgsVectorLayerdeleteFeature()
{
};
void QgsVectorLayerpendingFields()
{
};
void QgsVectorLayerpendingAllAttributesList()
{
};
void QgsVectorLayerpendingFeatureCount()
{
};
void QgsVectorLayercommitChanges()
{
};
void QgsVectorLayercommitErrors()
{
};
void QgsVectorLayerrollBack()
{
};
void QgsVectorLayersetSelectedFeatures()
{
};
void QgsVectorLayerselectedFeatureCount()
{
};
void QgsVectorLayerselectedFeaturesIds()
{
};
void QgsVectorLayerselectedFeatures()
{
};
void QgsVectorLayeraddFeatures()
{
};
void QgsVectorLayercopySymbologySettings()
{
};
void QgsVectorLayerhasCompatibleSymbology()
{
};
void QgsVectorLayersnapPoint()
{
};
void QgsVectorLayersnapWithContext()
{
};
void QgsVectorLayersnapToGeometry()
{
};
void QgsVectorLayerinsertSegmentVerticesForSnap()
{
};
void QgsVectorLayerboundingBoxFromPointList()
{
};
void QgsVectorLayercurrentVertexMarkerType()
{
};
void QgsVectorLayercurrentVertexMarkerSize()
{
};
void QgsVectorLayerdrawFeature()
{
};
void QgsVectorLayersetCoordinateSystem()
{
};
void QgsVectorLayertransformPoint()
{
};
void QgsVectorLayertransformPoints()
{
};
void QgsVectorLayerdisplayField()
{
};
void QgsVectorLayerisEditable()
{
};
void QgsVectorLayerisModified()
{
};
void QgsVectorLayersetModified()
{
};
void QgsVectorLayereditType()
{
};
void QgsVectorLayersetEditType()
{
};
void QgsVectorLayereditForm()
{
};
void QgsVectorLayersetEditForm()
{
};
void QgsVectorLayersetAnnotationForm()
{
};
void QgsVectorLayereditFormInit()
{
};
void QgsVectorLayersetEditFormInit()
{
};
void QgsVectorLayervalueMap()
{
};
void QgsVectorLayerrange()
{
};
void QgsVectorLayeraddOverlay()
{
};
void QgsVectorLayerremoveOverlay()
{
};
void QgsVectorLayervectorOverlays()
{
};
void QgsVectorLayerfindOverlayByType()
{
};
void QgsVectorLayerrendererV2()
{
};
void QgsVectorLayersetRendererV2()
{
QgsVectorLayer* vLayer = static_cast< QgsVectorLayer * >( mpPointsLayer );
@ -616,70 +302,27 @@ class TestQgsVectorLayer : public QObject
vLayer->setRendererV2( symbolRenderer );
QCOMPARE( receiver.rendererChanged, true );
QCOMPARE( vLayer->rendererV2(), symbolRenderer );
};
void QgsVectorLayerisUsingRendererV2()
{
};
void QgsVectorLayersetUsingRendererV2()
{
}
};
void QgsVectorLayereditGeometryChange()
{
};
void QgsVectorLayereditFeatureAdd()
{
};
void QgsVectorLayereditFeatureDelete()
{
};
void QgsVectorLayereditAttributeChange()
{
};
void QgsVectorLayerbeginEditCommand()
{
};
void QgsVectorLayerendEditCommand()
{
};
void QgsVectorLayerdestroyEditCommand()
{
};
void QgsVectorLayerredoEditCommand()
{
};
void QgsVectorLayerundoEditCommand()
{
};
void QgsVectorLayersetCheckedState()
{
};
void QgsVectorLayercheckedState()
{
};
void QgsVectorLayerfieldNameIndex()
{
};
void QgsVectorLayerstopRendererV2()
{
};
void QgsVectorLayerisUsingRendererV2() {}
void QgsVectorLayersetUsingRendererV2() {}
void QgsVectorLayereditGeometryChange() {}
void QgsVectorLayereditFeatureAdd() {}
void QgsVectorLayereditFeatureDelete() {}
void QgsVectorLayereditAttributeChange() {}
void QgsVectorLayerbeginEditCommand() {}
void QgsVectorLayerendEditCommand() {}
void QgsVectorLayerdestroyEditCommand() {}
void QgsVectorLayerredoEditCommand() {}
void QgsVectorLayerundoEditCommand() {}
void QgsVectorLayersetCheckedState() {}
void QgsVectorLayercheckedState() {}
void QgsVectorLayerfieldNameIndex() {}
void QgsVectorLayerstopRendererV2() {}
void QgsVectorLayersetFeatureBlendMode()
{
QgsVectorLayer* vLayer = static_cast< QgsVectorLayer * >( mpPointsLayer );
QgsVectorLayer *vLayer = static_cast< QgsVectorLayer * >( mpPointsLayer );
TestSignalReceiver receiver;
QObject::connect( vLayer, SIGNAL( featureBlendModeChanged( const QPainter::CompositionMode ) ),
&receiver, SLOT( onFeatureBlendModeChanged( const QPainter::CompositionMode ) ) );

View File

@ -214,7 +214,7 @@ bool TestZipLayer::testZipItem( QString myFileName, QString myChildName, QString
}
else
{
QWARN( QString( "Invalid layer %1" ).arg( layerItem->path() ).toLocal8Bit().data() );
QWARN( QString( "Invalid layer %1" ).arg( layerItem ? layerItem->path() : "(null)" ).toLocal8Bit().data() );
break;
}
}