mirror of
https://github.com/QuasarApp/DocsSite.git
synced 2025-05-08 01:09:34 +00:00
fix
This commit is contained in:
parent
46d7136718
commit
82f9c62a7b
@ -58,16 +58,8 @@ QQuickTextureFactory *AsyncImageResponse::textureFactory() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WASM
|
#ifdef Q_OS_WASM
|
||||||
static void *response = nullptr;
|
void AsyncImageResponse::downloadSucceeded(emscripten_fetch_t *fetch) {
|
||||||
#endif
|
auto resp = static_cast<AsyncImageResponse*>(fetch->userData);
|
||||||
|
|
||||||
void AsyncImageResponse::run() {
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_OS_WASM
|
|
||||||
response = this;
|
|
||||||
auto downloadSucceeded = [](emscripten_fetch_t *fetch) {
|
|
||||||
auto resp = static_cast<AsyncImageResponse*>(response);
|
|
||||||
resp->m_image = QImage::fromData(reinterpret_cast<const unsigned char*>(fetch->data),
|
resp->m_image = QImage::fromData(reinterpret_cast<const unsigned char*>(fetch->data),
|
||||||
fetch->numBytes);
|
fetch->numBytes);
|
||||||
|
|
||||||
@ -79,7 +71,7 @@ void AsyncImageResponse::run() {
|
|||||||
emscripten_fetch_close(fetch); // Free data associated with the fetch.
|
emscripten_fetch_close(fetch); // Free data associated with the fetch.
|
||||||
};
|
};
|
||||||
|
|
||||||
auto downloadFailed = [](emscripten_fetch_t *fetch) {
|
void AsyncImageResponse::downloadFailed(emscripten_fetch_t *fetch) {
|
||||||
|
|
||||||
QuasarAppUtils::Params::log(QString("Downloading %0 failed, HTTP failure status code: %1.\n").
|
QuasarAppUtils::Params::log(QString("Downloading %0 failed, HTTP failure status code: %1.\n").
|
||||||
arg(fetch->url).arg(fetch->status),
|
arg(fetch->url).arg(fetch->status),
|
||||||
@ -87,11 +79,18 @@ void AsyncImageResponse::run() {
|
|||||||
|
|
||||||
emscripten_fetch_close(fetch); // Also free data on failure.
|
emscripten_fetch_close(fetch); // Also free data on failure.
|
||||||
|
|
||||||
auto resp = static_cast<AsyncImageResponse*>(response);
|
auto resp = static_cast<AsyncImageResponse*>(fetch->userData);
|
||||||
resp->cancel();
|
resp->cancel();
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void AsyncImageResponse::run() {
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef Q_OS_WASM
|
||||||
emscripten_fetch_attr_t attr;
|
emscripten_fetch_attr_t attr;
|
||||||
|
attr.userData = this;
|
||||||
emscripten_fetch_attr_init(&attr);
|
emscripten_fetch_attr_init(&attr);
|
||||||
strcpy(attr.requestMethod, "GET");
|
strcpy(attr.requestMethod, "GET");
|
||||||
attr.attributes = EMSCRIPTEN_FETCH_LOAD_TO_MEMORY;
|
attr.attributes = EMSCRIPTEN_FETCH_LOAD_TO_MEMORY;
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
|
|
||||||
class QNetworkAccessManager;
|
class QNetworkAccessManager;
|
||||||
|
|
||||||
|
#ifdef Q_OS_WASM
|
||||||
|
class emscripten_fetch_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace BaseFront {
|
namespace BaseFront {
|
||||||
|
|
||||||
class BASEFRONT_LIBRARYSHARED_EXPORT AsyncImageResponse : public QQuickImageResponse, public QRunnable
|
class BASEFRONT_LIBRARYSHARED_EXPORT AsyncImageResponse : public QQuickImageResponse, public QRunnable
|
||||||
@ -33,6 +37,12 @@ private:
|
|||||||
QImage m_image;
|
QImage m_image;
|
||||||
QSize m_requestedSize;
|
QSize m_requestedSize;
|
||||||
|
|
||||||
|
private:
|
||||||
|
#ifdef Q_OS_WASM
|
||||||
|
|
||||||
|
static void downloadSucceeded(emscripten_fetch_t *fetch);
|
||||||
|
static void downloadFailed(emscripten_fetch_t *fetch);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class BASEFRONT_LIBRARYSHARED_EXPORT CorrentHostImageProvider: public QQuickAsyncImageProvider
|
class BASEFRONT_LIBRARYSHARED_EXPORT CorrentHostImageProvider: public QQuickAsyncImageProvider
|
||||||
|
Loading…
x
Reference in New Issue
Block a user