From 15ceb0279c46e286116a93b61f442de0105fcd0c Mon Sep 17 00:00:00 2001 From: Paolo Angelelli <paolo.angelelli@qt.io> Date: Wed, 12 Apr 2017 13:13:00 +0200 Subject: [PATCH] Fix for copyright notice not showing before map type is changed Task-number: QTBUG-58801 Change-Id: I2a980c6d218d0d7e44277f7b31fcdd7355e31698 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> --- .../declarativemaps/qdeclarativegeomap.cpp | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp index 81ef49ef3..3255a0f59 100644 --- a/src/location/declarativemaps/qdeclarativegeomap.cpp +++ b/src/location/declarativemaps/qdeclarativegeomap.cpp @@ -750,10 +750,23 @@ void QDeclarativeGeoMap::mappingManagerInitialized() // Map tiles are built in this call. m_map->minimumZoom() becomes operational // after this has been called at least once, after creation. - + // However, getting into the following block may fire a copyrightsChanged that would get lost, + // as the connections are set up after. + QString copyrightString; + QImage copyrightImage; if (!m_initialized && width() > 0 && height() > 0) { + QMetaObject::Connection copyrightStringCatcherConnection = + connect(m_map.data(), + QOverload<const QString &>::of(&QGeoMap::copyrightsChanged), + [©rightString](const QString ©){ copyrightString = copy; }); + QMetaObject::Connection copyrightImageCatcherConnection = + connect(m_map.data(), + QOverload<const QImage &>::of(&QGeoMap::copyrightsChanged), + [©rightImage](const QImage ©){ copyrightImage = copy; }); m_map->setViewportSize(QSize(width(), height())); initialize(); + QObject::disconnect(copyrightStringCatcherConnection); + QObject::disconnect(copyrightImageCatcherConnection); } m_copyrights = new QDeclarativeGeoMapCopyrightNotice(this); @@ -769,6 +782,11 @@ void QDeclarativeGeoMap::mappingManagerInitialized() connect(m_map.data(), SIGNAL(copyrightsChanged(QString)), this, SIGNAL(copyrightsChanged(QString))); + if (!copyrightString.isEmpty()) + emit m_map.data()->copyrightsChanged(copyrightString); + else if (!copyrightImage.isNull()) + emit m_map.data()->copyrightsChanged(copyrightImage); + connect(m_map.data(), SIGNAL(copyrightsStyleSheetChanged(QString)), m_copyrights.data(), SLOT(onCopyrightsStyleSheetChanged(QString))); -- GitLab