mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:36:47 +02:00
Merge pull request #7877 from Atlante45/fix/asset-client
Fix Asset Client crash
This commit is contained in:
commit
67891abf17
7 changed files with 17 additions and 11 deletions
|
@ -1,3 +1,3 @@
|
||||||
set(TARGET_NAME animation)
|
set(TARGET_NAME animation)
|
||||||
setup_hifi_library(Network Script)
|
setup_hifi_library(Network Script)
|
||||||
link_hifi_libraries(shared gpu model fbx)
|
link_hifi_libraries(shared model fbx)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
set(TARGET_NAME entities-renderer)
|
set(TARGET_NAME entities-renderer)
|
||||||
AUTOSCRIBE_SHADER_LIB(gpu model render render-utils)
|
AUTOSCRIBE_SHADER_LIB(gpu model render render-utils)
|
||||||
setup_hifi_library(Widgets Network Script)
|
setup_hifi_library(Widgets Network Script)
|
||||||
link_hifi_libraries(shared gpu procedural model model-networking script-engine render render-utils gl)
|
link_hifi_libraries(shared gpu procedural model model-networking script-engine render render-utils)
|
||||||
|
|
||||||
target_bullet()
|
target_bullet()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
set(TARGET_NAME entities)
|
set(TARGET_NAME entities)
|
||||||
setup_hifi_library(Network Script)
|
setup_hifi_library(Network Script)
|
||||||
link_hifi_libraries(avatars shared audio octree gpu model fbx networking animation)
|
link_hifi_libraries(avatars shared audio octree model fbx networking animation)
|
||||||
|
|
||||||
target_bullet()
|
target_bullet()
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
set(TARGET_NAME fbx)
|
set(TARGET_NAME fbx)
|
||||||
setup_hifi_library()
|
setup_hifi_library()
|
||||||
link_hifi_libraries(shared gpu model networking octree)
|
link_hifi_libraries(shared model networking)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
set(TARGET_NAME model-networking)
|
set(TARGET_NAME model-networking)
|
||||||
setup_hifi_library()
|
setup_hifi_library()
|
||||||
link_hifi_libraries(shared networking gpu model fbx)
|
link_hifi_libraries(shared networking model fbx)
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ AssetUpload* AssetClient::createUpload(const QByteArray& data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageID AssetClient::getAsset(const QString& hash, DataOffset start, DataOffset end,
|
MessageID AssetClient::getAsset(const QString& hash, DataOffset start, DataOffset end,
|
||||||
ReceivedAssetCallback callback, ProgressCallback progressCallback) {
|
ReceivedAssetCallback callback, ProgressCallback progressCallback) {
|
||||||
Q_ASSERT(QThread::currentThread() == thread());
|
Q_ASSERT(QThread::currentThread() == thread());
|
||||||
|
|
||||||
if (hash.length() != SHA256_HASH_HEX_LENGTH) {
|
if (hash.length() != SHA256_HASH_HEX_LENGTH) {
|
||||||
|
@ -238,8 +238,6 @@ MessageID AssetClient::getAsset(const QString& hash, DataOffset start, DataOffse
|
||||||
callback(false, AssetServerError::NoError, QByteArray());
|
callback(false, AssetServerError::NoError, QByteArray());
|
||||||
return INVALID_MESSAGE_ID;
|
return INVALID_MESSAGE_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageID AssetClient::getAssetInfo(const QString& hash, GetInfoCallback callback) {
|
MessageID AssetClient::getAssetInfo(const QString& hash, GetInfoCallback callback) {
|
||||||
|
|
|
@ -106,9 +106,13 @@ void AssetRequest::start() {
|
||||||
int start = 0, end = _info.size;
|
int start = 0, end = _info.size;
|
||||||
|
|
||||||
auto assetClient = DependencyManager::get<AssetClient>();
|
auto assetClient = DependencyManager::get<AssetClient>();
|
||||||
|
auto that = QPointer<AssetRequest>(this); // Used to track the request's lifetime
|
||||||
_assetRequestID = assetClient->getAsset(_hash, start, end,
|
_assetRequestID = assetClient->getAsset(_hash, start, end,
|
||||||
[this, start, end](bool responseReceived, AssetServerError serverError, const QByteArray& data) {
|
[this, that, start, end](bool responseReceived, AssetServerError serverError, const QByteArray& data) {
|
||||||
|
if (!that) {
|
||||||
|
// If the request is dead, return
|
||||||
|
return;
|
||||||
|
}
|
||||||
_assetRequestID = AssetClient::INVALID_MESSAGE_ID;
|
_assetRequestID = AssetClient::INVALID_MESSAGE_ID;
|
||||||
|
|
||||||
if (!responseReceived) {
|
if (!responseReceived) {
|
||||||
|
@ -148,7 +152,11 @@ void AssetRequest::start() {
|
||||||
|
|
||||||
_state = Finished;
|
_state = Finished;
|
||||||
emit finished(this);
|
emit finished(this);
|
||||||
}, [this](qint64 totalReceived, qint64 total) {
|
}, [this, that](qint64 totalReceived, qint64 total) {
|
||||||
|
if (!that) {
|
||||||
|
// If the request is dead, return
|
||||||
|
return;
|
||||||
|
}
|
||||||
emit progress(totalReceived, total);
|
emit progress(totalReceived, total);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue