Skip to content

Commit d9a2b35

Browse files
committedJun 29, 2015
fix some crash on invalid layers
(cherry picked from commit 34488f8 & 8fbee12)
1 parent 4050d44 commit d9a2b35

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed
 

‎python/core/qgsvectorlayer.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ class QgsVectorLayer : QgsMapLayer
284284
/** Removes a vector layer join */
285285
void removeJoin( const QString& joinLayerId );
286286

287-
const QList< QgsVectorJoinInfo >& vectorJoins() const;
287+
const QList< QgsVectorJoinInfo > vectorJoins() const;
288288

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

‎src/core/qgsvectorfilewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,7 @@ QgsVectorFileWriter::WriterError QgsVectorFileWriter::writeAsVectorFormat( QgsVe
18671867

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

1870-
if ( layer->providerType() == "ogr" )
1870+
if ( layer->providerType() == "ogr" && layer->dataProvider() )
18711871
{
18721872
QStringList theURIParts = layer->dataProvider()->dataSourceUri().split( "|" );
18731873
QString srcFileName = theURIParts[0];

‎src/core/qgsvectorlayer.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2840,7 +2840,7 @@ int QgsVectorLayer::fieldNameIndex( const QString& fieldName ) const
28402840

28412841
bool QgsVectorLayer::addJoin( const QgsVectorJoinInfo& joinInfo )
28422842
{
2843-
return mJoinBuffer->addJoin( joinInfo );
2843+
return mJoinBuffer && mJoinBuffer->addJoin( joinInfo );
28442844
}
28452845

28462846
void QgsVectorLayer::checkJoinLayerRemove( QString theLayerId )
@@ -2850,12 +2850,16 @@ void QgsVectorLayer::checkJoinLayerRemove( QString theLayerId )
28502850

28512851
void QgsVectorLayer::removeJoin( const QString& joinLayerId )
28522852
{
2853-
mJoinBuffer->removeJoin( joinLayerId );
2853+
if ( mJoinBuffer )
2854+
mJoinBuffer->removeJoin( joinLayerId );
28542855
}
28552856

2856-
const QList< QgsVectorJoinInfo >& QgsVectorLayer::vectorJoins() const
2857+
const QList< QgsVectorJoinInfo > QgsVectorLayer::vectorJoins() const
28572858
{
2858-
return mJoinBuffer->vectorJoins();
2859+
if ( mJoinBuffer )
2860+
return mJoinBuffer->vectorJoins();
2861+
else
2862+
return QList< QgsVectorJoinInfo >();
28592863
}
28602864

28612865
void QgsVectorLayer::addExpressionField( const QString& exp, const QgsField& fld )

‎src/core/qgsvectorlayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
647647
/** Removes a vector layer join */
648648
void removeJoin( const QString& joinLayerId );
649649

650-
const QList< QgsVectorJoinInfo >& vectorJoins() const;
650+
const QList<QgsVectorJoinInfo> vectorJoins() const;
651651

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

0 commit comments

Comments
 (0)
Please sign in to comment.