Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb38358p2' into 'mer-stable-on-5.6'
[qtlocation] Start Geoclue client position interface asynchronously. Contributes to JB#38358

See merge request !10
  • Loading branch information
chriadam committed Apr 20, 2017
2 parents 8770366 + 3020dff commit 69941ce
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/plugins/position/geoclue/qgeocluemaster.cpp
Expand Up @@ -80,6 +80,22 @@ bool QGeoclueMaster::hasMasterClient() const
return m_client && m_masterPosition;
}

void createGeoclueMasterClientPositionCallback(GeoclueMasterClient *,
GeocluePosition *position,
GError *error,
QGeoclueMaster *geoclueMaster)
{
if (error) {
qCritical("QGeoclueMaster failed to get master position object");
g_error_free(error);
g_object_unref(geoclueMaster->m_client);
geoclueMaster->m_client = 0;
return;
}

geoclueMaster->m_masterPosition = position;
}

bool QGeoclueMaster::createMasterClient(GeoclueAccuracyLevel accuracy, GeoclueResourceFlags resourceFlags)
{
Q_ASSERT(!m_client && !m_masterPosition);
Expand Down Expand Up @@ -121,13 +137,7 @@ bool QGeoclueMaster::createMasterClient(GeoclueAccuracyLevel accuracy, GeoclueRe

// Need to create the master position interface even though it will not be used, otherwise
// GetPositionProvider always returns empty strings.
m_masterPosition = geoclue_master_client_create_position(m_client, 0);
if (!m_masterPosition) {
qCritical("QGeoclueMaster failed to get master position object");
g_object_unref(m_client);
m_client = 0;
return false;
}
geoclue_master_client_create_position_async(m_client, reinterpret_cast<CreatePositionCallback>(createGeoclueMasterClientPositionCallback), this);

return true;
}
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/position/geoclue/qgeocluemaster.h
Expand Up @@ -61,6 +61,10 @@ class QGeoclueMaster
private:
GeoclueMasterClient *m_client;
GeocluePosition *m_masterPosition;
friend void createGeoclueMasterClientPositionCallback(GeoclueMasterClient *,
GeocluePosition *position,
GError *error,
QGeoclueMaster *geoclueMaster);

QObject *m_handler;
};
Expand Down

0 comments on commit 69941ce

Please sign in to comment.