File tree Expand file tree Collapse file tree 5 files changed +24
-13
lines changed Expand file tree Collapse file tree 5 files changed +24
-13
lines changed Original file line number Diff line number Diff line change @@ -515,6 +515,7 @@ Returns opposite bool value to operator ==
515
515
bool readXml( const QDomNode &node );
516
516
%Docstring
517
517
Restores state from the given DOM node.
518
+ If it fails or if the node is empty, a default not empty CRS will be returned.
518
519
519
520
:param node: The node from which state will be restored
520
521
Original file line number Diff line number Diff line change @@ -366,7 +366,8 @@ bool QgsLayerMetadata::readMetadataXml( const QDomElement &metadataElement )
366
366
367
367
// crs
368
368
mnl = metadataElement.namedItem ( QStringLiteral ( " crs" ) );
369
- mCrs .readXml ( mnl );
369
+ if ( !mCrs .readXml ( mnl ) )
370
+ mCrs = QgsCoordinateReferenceSystem ();
370
371
371
372
// extent
372
373
mnl = metadataElement.namedItem ( QStringLiteral ( " extent" ) );
Original file line number Diff line number Diff line change @@ -466,6 +466,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
466
466
467
467
/* *
468
468
* Restores state from the given DOM node.
469
+ * If it fails or if the node is empty, a default not empty CRS will be returned.
469
470
* \param node The node from which state will be restored
470
471
* \returns bool True on success, False on failure
471
472
*/
Original file line number Diff line number Diff line change @@ -4032,12 +4032,16 @@ QString QgsVectorLayer::htmlMetadata() const
4032
4032
}
4033
4033
4034
4034
// EPSG
4035
- myMetadata += QStringLiteral ( " <tr><td class=\" highlight\" >" ) + tr ( " CRS" ) + QStringLiteral ( " </td><td>" ) + crs ().authid () + QStringLiteral ( " - " );
4036
- myMetadata += crs ().description () + QStringLiteral ( " - " );
4037
- if ( crs ().isGeographic () )
4038
- myMetadata += tr ( " Geographic" );
4039
- else
4040
- myMetadata += tr ( " Projected" );
4035
+ myMetadata += QStringLiteral ( " <tr><td class=\" highlight\" >" ) + tr ( " CRS" ) + QStringLiteral ( " </td><td>" );
4036
+ if ( crs ().isValid () )
4037
+ {
4038
+ myMetadata += crs ().authid () + QStringLiteral ( " - " );
4039
+ myMetadata += crs ().description () + QStringLiteral ( " - " );
4040
+ if ( crs ().isGeographic () )
4041
+ myMetadata += tr ( " Geographic" );
4042
+ else
4043
+ myMetadata += tr ( " Projected" );
4044
+ }
4041
4045
myMetadata += QLatin1String ( " </td></tr>\n " );
4042
4046
4043
4047
// Extent
Original file line number Diff line number Diff line change @@ -324,12 +324,16 @@ QString QgsRasterLayer::htmlMetadata() const
324
324
myMetadata += QStringLiteral ( " <tr><td class=\" highlight\" >" ) + tr ( " Provider" ) + QStringLiteral ( " </td><td>" ) + providerType () + QStringLiteral ( " </td></tr>\n " );
325
325
326
326
// EPSG
327
- myMetadata += QStringLiteral ( " <tr><td class=\" highlight\" >" ) + tr ( " CRS" ) + QStringLiteral ( " </td><td>" ) + crs ().authid () + QStringLiteral ( " - " );
328
- myMetadata += crs ().description () + QStringLiteral ( " - " );
329
- if ( crs ().isGeographic () )
330
- myMetadata += tr ( " Geographic" );
331
- else
332
- myMetadata += tr ( " Projected" );
327
+ myMetadata += QStringLiteral ( " <tr><td class=\" highlight\" >" ) + tr ( " CRS" ) + QStringLiteral ( " </td><td>" );
328
+ if ( crs ().isValid () )
329
+ {
330
+ myMetadata += crs ().authid () + QStringLiteral ( " - " );
331
+ myMetadata += crs ().description () + QStringLiteral ( " - " );
332
+ if ( crs ().isGeographic () )
333
+ myMetadata += tr ( " Geographic" );
334
+ else
335
+ myMetadata += tr ( " Projected" );
336
+ }
333
337
myMetadata += QLatin1String ( " </td></tr>\n " );
334
338
335
339
// Extent
You can’t perform that action at this time.
0 commit comments