diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2021-02-26 17:54:41 +0100 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2021-03-02 17:14:33 +0100 |
commit | 1c2b781dc36bdda06696ff2111fd3d0f7c56578c (patch) | |
tree | 72e4b8736e671a6551edb1fa665a6b24ed703b38 /src/plugins | |
parent | 58b7f95e9ca3ca84e004a26d77ecbe90ea874ea2 (diff) | |
download | qtlocation-1c2b781dc36bdda06696ff2111fd3d0f7c56578c.tar.gz |
QtPositioning: increase control object lifetime in GYPSY plugin
For some reason the GObject control object was destroyed as soon as
the device was created.
With the current version of glib it results in immediate destruction
of all the created objects, so the newly created device got destroyed
as well. As a result, the plugin was unusable.
This patch extends the lifetime of the main control object for the
lifetime of the whole plugin.
Change-Id: I2ff2d40dea33b89c70f1f1188569f06fed4c88d9
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp | 10 | ||||
-rw-r--r-- | src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy_p.h | 1 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp b/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp index 1c588916..abd6c3b6 100644 --- a/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp +++ b/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp @@ -163,6 +163,8 @@ QGeoSatelliteInfoSourceGypsy::~QGeoSatelliteInfoSourceGypsy() } if (m_satellite) g_object_unref(m_satellite); + if (m_control) + g_object_unref(m_control); if (error) g_error_free(error); delete m_engine; @@ -240,17 +242,15 @@ int QGeoSatelliteInfoSourceGypsy::init() m_engine->eng_g_free(device_name); return -1; } - GypsyControl *control = NULL; - control = m_engine->eng_gypsy_control_get_default(); - if (!control) { + m_control = m_engine->eng_gypsy_control_get_default(); + if (!m_control) { qWarning("QGeoSatelliteInfoSourceGypsy unable to create Gypsy control."); m_engine->eng_g_free(device_name); return -1; } // (path is the DBus path) - path = m_engine->eng_gypsy_control_create (control, device_name, &error); + path = m_engine->eng_gypsy_control_create (m_control, device_name, &error); m_engine->eng_g_free(device_name); - g_object_unref(control); if (!path) { qWarning ("QGeoSatelliteInfoSourceGypsy error creating client."); if (error) { diff --git a/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy_p.h b/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy_p.h index b393ce3f..ededf168 100644 --- a/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy_p.h +++ b/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy_p.h @@ -138,6 +138,7 @@ private: bool m_updatesOngoing; bool m_requestOngoing; QGeoSatelliteInfoSource::Error m_error = QGeoSatelliteInfoSource::NoError; + GypsyControl *m_control = nullptr; }; QT_END_NAMESPACE |