Skip to content
Permalink
Browse files

fix some crash on invalid layers

(cherry picked from commit 34488f8 & 8fbee12)
  • Loading branch information
jef-n committed Jun 13, 2015
1 parent 4050d44 commit d9a2b3527feca09b779be44425010b55d2dbde93
Showing with 11 additions and 7 deletions.
  1. +1 −1 python/core/qgsvectorlayer.sip
  2. +1 −1 src/core/qgsvectorfilewriter.cpp
  3. +8 −4 src/core/qgsvectorlayer.cpp
  4. +1 −1 src/core/qgsvectorlayer.h
@@ -284,7 +284,7 @@ class QgsVectorLayer : QgsMapLayer
/** Removes a vector layer join */
void removeJoin( const QString& joinLayerId );

const QList< QgsVectorJoinInfo >& vectorJoins() const;
const QList< QgsVectorJoinInfo > vectorJoins() const;

/**
* Add a new field which is calculated by the expression specified
@@ -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];
@@ -2840,7 +2840,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 )
@@ -2850,12 +2850,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
const QList< QgsVectorJoinInfo > QgsVectorLayer::vectorJoins() const
{
return mJoinBuffer->vectorJoins();
if ( mJoinBuffer )
return mJoinBuffer->vectorJoins();
else
return QList< QgsVectorJoinInfo >();
}

void QgsVectorLayer::addExpressionField( const QString& exp, const QgsField& fld )
@@ -647,7 +647,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/** Removes a vector layer join */
void removeJoin( const QString& joinLayerId );

const QList< QgsVectorJoinInfo >& vectorJoins() const;
const QList<QgsVectorJoinInfo> vectorJoins() const;

/**
* Add a new field which is calculated by the expression specified

0 comments on commit d9a2b35

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