mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
android/usb: better memory management
Instead of relying on the std::vector staying unchanged and not freeing its members, instead keep a copy of the object in our DCDeviceData class. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
0b72495413
commit
2265a27912
3 changed files with 12 additions and 4 deletions
|
@ -324,9 +324,10 @@ void DCDeviceData::setDevName(const QString &devName)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
void DCDeviceData::setUsbDevice(void *device)
|
void DCDeviceData::setUsbDevice(const android_usb_serial_device_descriptor &usbDescriptor)
|
||||||
{
|
{
|
||||||
data.androidUsbDeviceDescriptor = device;
|
androidUsbDescriptor = usbDescriptor;
|
||||||
|
data.androidUsbDeviceDescriptor = &androidUsbDescriptor;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,10 @@
|
||||||
#if BT_SUPPORT
|
#if BT_SUPPORT
|
||||||
#include "core/btdiscovery.h"
|
#include "core/btdiscovery.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
#include "core/serial_usb_android.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Helper object for access of Device Data in QML */
|
/* Helper object for access of Device Data in QML */
|
||||||
class DCDeviceData {
|
class DCDeviceData {
|
||||||
public:
|
public:
|
||||||
|
@ -50,9 +54,12 @@ public:
|
||||||
void setSaveDump(bool dumpMode);
|
void setSaveDump(bool dumpMode);
|
||||||
void setSaveLog(bool saveLog);
|
void setSaveLog(bool saveLog);
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
void setUsbDevice(void *device);
|
void setUsbDevice(const android_usb_serial_device_descriptor &usbDescriptor);
|
||||||
#endif
|
#endif
|
||||||
private:
|
private:
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
struct android_usb_serial_device_descriptor androidUsbDescriptor;
|
||||||
|
#endif
|
||||||
device_data_t data;
|
device_data_t data;
|
||||||
|
|
||||||
// Bluetooth name is managed outside of libdivecomputer
|
// Bluetooth name is managed outside of libdivecomputer
|
||||||
|
|
|
@ -2024,7 +2024,7 @@ void QMLManager::DC_setDevName(const QString& devName)
|
||||||
for (unsigned int i = 0; i < androidSerialDevices.size(); i++) {
|
for (unsigned int i = 0; i < androidSerialDevices.size(); i++) {
|
||||||
if (androidSerialDevices[i].uiRepresentation == connection) {
|
if (androidSerialDevices[i].uiRepresentation == connection) {
|
||||||
appendTextToLog(QString("setDevName matches USB device %1").arg(i));
|
appendTextToLog(QString("setDevName matches USB device %1").arg(i));
|
||||||
DCDeviceData::instance()->setUsbDevice((void *)&androidSerialDevices[i]);
|
DCDeviceData::instance()->setUsbDevice(androidSerialDevices[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue