Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb34945' into 'mer-stable'
[QtLocation] Use Qt event loop to emit signals from GLib callbacks. Contributes to JB#34945

This commit ensures that we use Qt::QueuedConnection to emit signals
(or invoke functions which emit signals) within codepaths which are
entered from the glib event loop, to avoid QTBUG-18434.

Contributes to JB#34945

See merge request !4
  • Loading branch information
chriadam committed May 19, 2016
2 parents c7dff74 + 55009ec commit 742ed87
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Expand Up @@ -200,7 +200,8 @@ void QGeoPositionInfoSourceGeoclueMaster::regularUpdateFailed()
m_lastVelocityIsFresh = false;
if (m_running && !m_regularUpdateTimedOut) {
m_regularUpdateTimedOut = true;
emit updateTimeout();
// use a QueuedConnection to emit the signal to ensure that we enter the Qt event loop.
QMetaObject::invokeMethod(this, "updateTimeout", Qt::QueuedConnection);
}
}

Expand Down Expand Up @@ -244,7 +245,8 @@ void QGeoPositionInfoSourceGeoclueMaster::updatePosition(GeocluePositionFields f

m_regularUpdateTimedOut = false;

emit positionUpdated(m_lastPosition);
// use a QueuedConnection to emit the signal to ensure that we enter the Qt event loop.
QMetaObject::invokeMethod(this, "positionUpdated", Qt::QueuedConnection, Q_ARG(QGeoPositionInfo, m_lastPosition));

#ifdef Q_LOCATION_GEOCLUE_DEBUG
qDebug() << "Lat, lon, alt, speed:"
Expand Down
Expand Up @@ -81,7 +81,13 @@ void satellite_changed(GeoclueSatellite *satellite, int timestamp, int satellite
satInfos.append(satInfo);
}

source->satelliteChanged(timestamp, satellite_used, satellite_visible, usedPrns, satInfos);
// use a QueuedConnection to ensure that we enter the Qt event loop.
QMetaObject::invokeMethod(source, "satelliteChanged", Qt::QueuedConnection,
Q_ARG(int, timestamp),
Q_ARG(int, satellite_used),
Q_ARG(int, satellite_visible),
Q_ARG(QList<int>, usedPrns),
Q_ARG(QList<QGeoSatelliteInfo>, satInfos));
}

void satellite_callback(GeoclueSatellite *satellite, int timestamp, int satellite_used,
Expand Down Expand Up @@ -116,7 +122,13 @@ void satellite_callback(GeoclueSatellite *satellite, int timestamp, int satellit
satInfos.append(satInfo);
}

source->requestUpdateFinished(timestamp, satellite_used, satellite_visible, usedPrns, satInfos);
// use a QueuedConnection to ensure that we enter the Qt event loop.
QMetaObject::invokeMethod(source, "requestUpdateFinished", Qt::QueuedConnection,
Q_ARG(int, timestamp),
Q_ARG(int, satellite_used),
Q_ARG(int, satellite_visible),
Q_ARG(QList<int>, usedPrns),
Q_ARG(QList<QGeoSatelliteInfo>, satInfos));
}

}
Expand Down

0 comments on commit 742ed87

Please sign in to comment.