Skip to content
Permalink
Browse files

PyQgis: don't crash on invalid provider

Related to #35354
  • Loading branch information
elpaso authored and nyalldawson committed Mar 25, 2020
1 parent e7556c4 commit 5b965ce704a05306bc42431ba07f284c1f02ebab
Showing with 2 additions and 2 deletions.
  1. +1 −1 python/core/auto_generated/qgsmaplayer.sip.in
  2. +1 −1 src/core/qgsmaplayer.h
@@ -1419,7 +1419,7 @@ Sets the coordinate transform context to ``transformContext``

SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsMapLayer: '%1' (%2)>" ).arg( sipCpp->name(), sipCpp->dataProvider()->name() );
QString str = QStringLiteral( "<QgsMapLayer: '%1' (%2)>" ).arg( sipCpp->name(), sipCpp->dataProvider() ? sipCpp->dataProvider()->name() : QStringLiteral( "Invalid" ) );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

@@ -1273,7 +1273,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsMapLayer: '%1' (%2)>" ).arg( sipCpp->name(), sipCpp->dataProvider()->name() );
QString str = QStringLiteral( "<QgsMapLayer: '%1' (%2)>" ).arg( sipCpp->name(), sipCpp->dataProvider() ? sipCpp->dataProvider()->name() : QStringLiteral( "Invalid" ) );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

0 comments on commit 5b965ce

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