diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-10-14 17:46:16 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-10-14 17:46:34 +0200 |
commit | 440286655e0ca271506cf7cc02ad0dbf4baef9ca (patch) | |
tree | 896fa81adb8b14a69355a3a6cf64d06ec8173c9a /src/network/access/qnetworkreplywasmimpl.cpp | |
parent | 1e27ad1697187549151657ba187928e439300db7 (diff) | |
parent | e164d61ca8263fc4b46fdd916e1ea77c7dd2b735 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: I4a78428a8ea273b6960792e3b8043f816fa37fcf
Diffstat (limited to 'src/network/access/qnetworkreplywasmimpl.cpp')
-rw-r--r-- | src/network/access/qnetworkreplywasmimpl.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/network/access/qnetworkreplywasmimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp index 53784407d8..f28b8415d1 100644 --- a/src/network/access/qnetworkreplywasmimpl.cpp +++ b/src/network/access/qnetworkreplywasmimpl.cpp @@ -63,6 +63,8 @@ static void q_requestErrorCallback(val event) return; val xhr = event["target"]; + if (xhr.isNull() || xhr.isUndefined()) + return; quintptr func = xhr["data-handler"].as<quintptr>(); QNetworkReplyWasmImplPrivate *reply = reinterpret_cast<QNetworkReplyWasmImplPrivate*>(func); @@ -84,6 +86,8 @@ static void q_progressCallback(val event) return; val xhr = event["target"]; + if (xhr.isNull() || xhr.isUndefined()) + return; QNetworkReplyWasmImplPrivate *reply = reinterpret_cast<QNetworkReplyWasmImplPrivate*>(xhr["data-handler"].as<quintptr>()); @@ -99,6 +103,8 @@ static void q_loadCallback(val event) return; val xhr = event["target"]; + if (xhr.isNull() || xhr.isUndefined()) + return; QNetworkReplyWasmImplPrivate *reply = reinterpret_cast<QNetworkReplyWasmImplPrivate*>(xhr["data-handler"].as<quintptr>()); @@ -123,8 +129,13 @@ static void q_loadCallback(val event) } else if (responseType == "arraybuffer" || responseType == "blob") { // handle this data in the FileReader, triggered by the call to readAsArrayBuffer val blob = xhr["response"]; + if (blob.isNull() || blob.isUndefined()) + return; val reader = val::global("FileReader").new_(); + if (reader.isNull() || reader.isUndefined()) + return; + reader.set("onload", val::module_property("qt_QNetworkReplyWasmImplPrivate_readBinary")); reader.set("data-handler", xhr["data-handler"]); @@ -151,6 +162,8 @@ static void q_responseHeadersCallback(val event) return; val xhr = event["target"]; + if (xhr.isNull() || xhr.isUndefined()) + return; if (xhr["readyState"].as<int>() == 2) { // HEADERS_RECEIVED std::string responseHeaders = xhr.call<std::string>("getAllResponseHeaders"); @@ -170,6 +183,8 @@ static void q_readBinary(val event) return; val fileReader = event["target"]; + if (fileReader.isNull() || fileReader.isUndefined()) + return; QNetworkReplyWasmImplPrivate *reply = reinterpret_cast<QNetworkReplyWasmImplPrivate*>(fileReader["data-handler"].as<quintptr>()); @@ -180,6 +195,9 @@ static void q_readBinary(val event) // Set up source typed array val result = fileReader["result"]; // ArrayBuffer + if (result.isNull() || result.isUndefined()) + return; + val Uint8Array = val::global("Uint8Array"); val sourceTypedArray = Uint8Array.new_(result); |