1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #5184

Pavel Karelin (1):
      fix: Fix PR #5182. Eliminating the 'new' operator at ToxOptionsWrapper
This commit is contained in:
sudden6 2018-06-23 12:46:42 +02:00
commit 254b861ded
No known key found for this signature in database
GPG Key ID: 279509B499E032B9

View File

@ -123,36 +123,33 @@ namespace {
class ToxOptionsWrapper class ToxOptionsWrapper
{ {
public: public:
ToxOptionsWrapper(Tox_Options *options, const QByteArray& proxyAddrData) { ToxOptionsWrapper(Tox_Options *options, const QByteArray& proxyAddrData)
this->options = options; : options(options)
this->proxyAddrData = new QByteArray(proxyAddrData); , proxyAddrData(proxyAddrData)
} {}
~ToxOptionsWrapper() { ~ToxOptionsWrapper() {
tox_options_free(options); tox_options_free(options);
options = nullptr;
delete proxyAddrData;
proxyAddrData = nullptr;
} }
ToxOptionsWrapper (ToxOptionsWrapper && from) { ToxOptionsWrapper (ToxOptionsWrapper && from) {
this->options = from.options; options = from.options;
proxyAddrData.swap(from.proxyAddrData);
from.options = nullptr; from.options = nullptr;
this->proxyAddrData = from.proxyAddrData; from.proxyAddrData.clear();
from.proxyAddrData = nullptr;
} }
operator Tox_Options* () { operator Tox_Options* () {
return options; return options;
} }
const char* getProxyAddrData() { const char* getProxyAddrData() const {
return this->proxyAddrData->data(); return proxyAddrData.constData();
} }
private: private:
Tox_Options *options = nullptr; Tox_Options *options = nullptr;
QByteArray *proxyAddrData = nullptr; QByteArray proxyAddrData;
}; };
/** /**