Skip to content

Commit

Permalink
QgsMapLayer::crs() now returns a copy, not a reference
Browse files Browse the repository at this point in the history
(desirable because QgsCoordinateReferenceSystem is implicitly shared)
  • Loading branch information
nyalldawson committed Jul 14, 2016
1 parent a2efab0 commit 726569c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
6 changes: 6 additions & 0 deletions doc/api_break.dox
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ objects are implicitly shared, returning a copy helps simplify and make code mor
only affects third party c++ providers, and does not affect PyQGIS scripts.</li>
</ul>

\subsection qgis_api_break_3_0_QgsMapLayer QgsMapLayer

<ul>
<li>crs() now returns a QgsCoordinateReferenceSystem object, not a reference. This change has no effect for PyQGIS code.</li>
</ul>

\subsection qgis_api_break_3_0_QgsVectorLayerImport QgsVectorLayerImport

<ul>
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsmaplayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ class QgsMapLayer : QObject
/** Returns layer's spatial reference system
@note This was introduced in QGIS 1.4
*/
const QgsCoordinateReferenceSystem& crs() const;
QgsCoordinateReferenceSystem crs() const;

/** Sets layer's spatial reference system */
void setCrs( const QgsCoordinateReferenceSystem& srs, bool emitSignal = true );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsmaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ void QgsMapLayer::setSubLayerVisibility( const QString& name, bool vis )
// NOOP
}

const QgsCoordinateReferenceSystem& QgsMapLayer::crs() const
QgsCoordinateReferenceSystem QgsMapLayer::crs() const
{
return mCRS;
}
Expand Down
3 changes: 1 addition & 2 deletions src/core/qgsmaplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
/** Returns layer's spatial reference system
@note This was introduced in QGIS 1.4
*/
//TODO QGIS 3.0 - return QgsCoordinateReferenceSystem object, not reference (since they are implicitly shared)
const QgsCoordinateReferenceSystem& crs() const;
QgsCoordinateReferenceSystem crs() const;

/** Sets layer's spatial reference system */
void setCrs( const QgsCoordinateReferenceSystem& srs, bool emitSignal = true );
Expand Down

0 comments on commit 726569c

Please sign in to comment.