Skip to content

Commit

Permalink
fix some crash on invalid layers
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jun 13, 2015
1 parent 244f998 commit 34488f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/qgsvectorfilewriter.cpp
Expand Up @@ -1867,7 +1867,7 @@ QgsVectorFileWriter::WriterError QgsVectorFileWriter::writeAsVectorFormat( QgsVe

QGis::WkbType wkbType = layer->wkbType();

if ( layer->providerType() == "ogr" )
if ( layer->providerType() == "ogr" && layer->dataProvider() )
{
QStringList theURIParts = layer->dataProvider()->dataSourceUri().split( "|" );
QString srcFileName = theURIParts[0];
Expand Down
10 changes: 7 additions & 3 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -2858,7 +2858,7 @@ int QgsVectorLayer::fieldNameIndex( const QString& fieldName ) const

bool QgsVectorLayer::addJoin( const QgsVectorJoinInfo& joinInfo )
{
return mJoinBuffer->addJoin( joinInfo );
return mJoinBuffer && mJoinBuffer->addJoin( joinInfo );
}

void QgsVectorLayer::checkJoinLayerRemove( QString theLayerId )
Expand All @@ -2868,12 +2868,16 @@ void QgsVectorLayer::checkJoinLayerRemove( QString theLayerId )

void QgsVectorLayer::removeJoin( const QString& joinLayerId )
{
mJoinBuffer->removeJoin( joinLayerId );
if ( mJoinBuffer )
mJoinBuffer->removeJoin( joinLayerId );
}

const QList< QgsVectorJoinInfo >& QgsVectorLayer::vectorJoins() const
{
return mJoinBuffer->vectorJoins();
if ( mJoinBuffer )
return mJoinBuffer->vectorJoins();
else
return QList< QgsVectorJoinInfo >();
}

int QgsVectorLayer::addExpressionField( const QString& exp, const QgsField& fld )
Expand Down

0 comments on commit 34488f8

Please sign in to comment.