Showing the changes to libraries/script-engine/src/XMLHttpRequestClass.cpp (1 of 2 files). Show all
Unified · Split
| @@ -30,30 +30,14 @@ Q_DECLARE_METATYPE(QByteArray*) · 29 unmodified lines | ||
| 30 | 30 | |
| 31 | 31 | XMLHttpRequestClass::XMLHttpRequestClass(QScriptEngine* engine) : |
| 32 | 32 | _engine(engine), |
| 33 | − _async(true), | |
| 34 | − _url(), | |
| 35 | − _method(""), | |
| 36 | − _responseType(""), | |
| 37 | − _request(), | |
| 38 | − _reply(NULL), | |
| 39 | − _sendData(NULL), | |
| 40 | − _rawResponseData(), | |
| 41 | − _responseData(""), | |
| 42 | − _onTimeout(QScriptValue::NullValue), | |
| 43 | − _onReadyStateChange(QScriptValue::NullValue), | |
| 44 | − _readyState(XMLHttpRequestClass::UNSENT), | |
| 45 | − _errorCode(QNetworkReply::NoError), | |
| 46 | − _timeout(0), | |
| 47 | − _timer(this), | |
| 48 | − _numRedirects(0) { | |
| 33 | + _timer(this) { | |
| 49 | 34 | |
| 50 | 35 | _request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); |
| 51 | 36 | _timer.setSingleShot(true); |
| 52 | 37 | } |
| 53 | 38 | |
| 54 | 39 | XMLHttpRequestClass::~XMLHttpRequestClass() { |
| 55 | − if (_reply) { delete _reply; } | |
| 56 | − if (_sendData) { delete _sendData; } | |
| 40 | + if (_reply) { _reply->deleteLater(); } | |
| 57 | 41 | } |
| 58 | 42 | |
| 59 | 43 | QScriptValue XMLHttpRequestClass::constructor(QScriptContext* context, QScriptEngine* engine) { |
| @@ -169,13 +153,12 @@ void XMLHttpRequestClass::send() { · 109 unmodified lines | ||
| 169 | 153 | |
| 170 | 154 | void XMLHttpRequestClass::send(const QScriptValue& data) { |
| 171 | 155 | if (_readyState == OPENED && !_reply) { |
| 156 | + | |
| 172 | 157 | if (!data.isNull()) { |
| 173 | − _sendData = new QBuffer(this); | |
| 174 | 158 | if (data.isObject()) { |
| 175 | − QByteArray ba = qscriptvalue_cast<QByteArray>(data); | |
| 176 | − _sendData->setData(ba); | |
| 159 | + _sendData = qscriptvalue_cast<QByteArray>(data); | |
| 177 | 160 | } else { |
| 178 | − _sendData->setData(data.toString().toUtf8()); | |
| 161 | + _sendData = data.toString().toUtf8(); | |
| 179 | 162 | } |
| 180 | 163 | } |
| 181 | 164 | |
| @@ -235,6 +218,10 @@ void XMLHttpRequestClass::requestFinished() { · 53 unmodified lines | ||
| 235 | 218 | } |
| 236 | 219 | } |
| 237 | 220 | |
| 221 | + disconnectFromReply(_reply); | |
| 222 | + _reply->deleteLater(); | |
| 223 | + _reply = nullptr; | |
| 224 | + | |
| 238 | 225 | setReadyState(DONE); |
| 239 | 226 | emit requestComplete(); |
| 240 | 227 | } |
| @@ -246,7 +233,7 @@ void XMLHttpRequestClass::abortRequest() { · 5 unmodified lines | ||
| 246 | 233 | disconnectFromReply(_reply); |
| 247 | 234 | _reply->abort(); |
| 248 | 235 | _reply->deleteLater(); |
| 249 | − _reply = NULL; | |
| 236 | + _reply = nullptr; | |
| 250 | 237 | } |
| 251 | 238 | } |
| 252 | 239 | |