diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-02-28 23:37:09 +0100 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-03-14 13:55:36 +0200 |
commit | d1572a8d9574e80955796b8667317c8dbd376081 (patch) | |
tree | ab58f9920a20b5c55bd54474f2edcfdc4eb2b904 /core/downloadfromdcthread.cpp | |
parent | b72cc1f31784346884c8552c22f1e4c3c6d5ed1d (diff) | |
download | subsurface-d1572a8d9574e80955796b8667317c8dbd376081.tar.gz |
Cleanup: introduce copy_qstring() function
strdup(qPrintable(s)) and copy_string(qPrintable(s)) were such common
occurrences that they seem worthy of a short helper-function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/downloadfromdcthread.cpp')
-rw-r--r-- | core/downloadfromdcthread.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp index dfbeb244d..ea803e20b 100644 --- a/core/downloadfromdcthread.cpp +++ b/core/downloadfromdcthread.cpp @@ -1,5 +1,6 @@ #include "downloadfromdcthread.h" #include "core/libdivecomputer.h" +#include "core/qthelper.h" #include "core/subsurface-qt/SettingsObjectWrapper.h" #include <QDebug> #include <QRegularExpression> @@ -281,12 +282,12 @@ int DCDeviceData::diveId() const void DCDeviceData::setVendor(const QString& vendor) { - data.vendor = strdup(qPrintable(vendor)); + data.vendor = copy_qstring(vendor); } void DCDeviceData::setProduct(const QString& product) { - data.product = strdup(qPrintable(product)); + data.product = copy_qstring(product); } void DCDeviceData::setDevName(const QString& devName) @@ -303,11 +304,11 @@ void DCDeviceData::setDevName(const QString& devName) QString back = devName.mid(idx1 + 1, idx2 - idx1 - 1); QString newDevName = back.indexOf(':') >= 0 ? back : front; qWarning() << "Found invalid bluetooth device" << devName << "corrected to" << newDevName << "."; - data.devname = strdup(qPrintable(newDevName)); + data.devname = copy_qstring(newDevName); return; } } - data.devname = strdup(qPrintable(devName)); + data.devname = copy_qstring(devName); } void DCDeviceData::setDevBluetoothName(const QString& name) |