From 32548b85a9f75997e23cbd100210fa3c8a199b4d Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Thu, 8 Jun 2017 18:28:44 +0200 Subject: Fix for QDeclarativeGeoMapCopyrightNotice crashing the application Some pointers were used without prior check. This adds checks where necessary. Change-Id: I82e01b72fd3a46a6add7cf286e81686b686b272b Reviewed-by: Alex Blasche --- .../qdeclarativegeomapcopyrightsnotice.cpp | 21 +++++++++++++++------ .../qdeclarativegeomapcopyrightsnotice_p.h | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp index 1101eb18..1a8489eb 100644 --- a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp +++ b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp @@ -129,20 +129,29 @@ void QDeclarativeGeoMapCopyrightNotice::setMapSource(QDeclarativeGeoMap *mapSour if (mapSource) { m_mapSource = mapSource; // First update the copyright. Only Image will do here, no need to store HTML right away. - if (!mapSource->m_copyrights->m_copyrightsImage.isNull()) + if (mapSource->m_copyrights && !mapSource->m_copyrights->m_copyrightsImage.isNull()) m_copyrightsImage = mapSource->m_copyrights->m_copyrightsImage; connect(m_mapSource, SIGNAL(copyrightsChanged(QImage)), this, SLOT(copyrightsChanged(QImage))); connect(m_mapSource, SIGNAL(copyrightsChanged(QString)), this, SLOT(copyrightsChanged(QString))); - connect(m_mapSource->m_map, SIGNAL(copyrightsStyleSheetChanged(QString)), - this, SLOT(onCopyrightsStyleSheetChanged(QString))); - connect(this, SIGNAL(linkActivated(QString)), - m_mapSource, SIGNAL(copyrightLinkActivated(QString))); - onCopyrightsStyleSheetChanged(m_mapSource->m_map->copyrightsStyleSheet()); + if (m_mapSource->m_map) + connectMap(); + else + connect(m_mapSource, &QDeclarativeGeoMap::mapReadyChanged, this, &QDeclarativeGeoMapCopyrightNotice::connectMap); } +} + +void QDeclarativeGeoMapCopyrightNotice::connectMap() +{ + connect(m_mapSource->m_map, SIGNAL(copyrightsStyleSheetChanged(QString)), + this, SLOT(onCopyrightsStyleSheetChanged(QString))); + connect(this, SIGNAL(linkActivated(QString)), + m_mapSource, SIGNAL(copyrightLinkActivated(QString))); + + onCopyrightsStyleSheetChanged(m_mapSource->m_map->copyrightsStyleSheet()); update(); emit mapSourceChanged(); diff --git a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h index b09d7c1d..0d7f7a20 100644 --- a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h +++ b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h @@ -96,6 +96,7 @@ protected: void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void rasterizeHtmlAndUpdate(); + void connectMap(); private: void createCopyright(); -- cgit v1.2.3