HTTP texture fetch endless append fix, by Laika Tungsten

Please don't consider this ready yet.
This commit is contained in:
Siana Gearz
2012-03-21 19:03:23 +01:00
parent f885c8667b
commit b4bdb7ca36

View File

@@ -1316,6 +1316,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
LLImageBase::TYPE_AVATAR_BAKE == mType); LLImageBase::TYPE_AVATAR_BAKE == mType);
#endif #endif
if(cur_size > 0) offset--;
// Will call callbackHttpGet when curl request completes // Will call callbackHttpGet when curl request completes
std::vector<std::string> headers; std::vector<std::string> headers;
headers.push_back("Accept: image/x-j2c"); headers.push_back("Accept: image/x-j2c");
@@ -1460,11 +1461,14 @@ bool LLTextureFetchWorker::doWork(S32 param)
} }
U8* buffer = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), mBufferSize); U8* buffer = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), mBufferSize);
if (cur_size > 0) if (cur_size > 0) {
{
memcpy(buffer, mFormattedImage->getData(), cur_size); memcpy(buffer, mFormattedImage->getData(), cur_size);
mBufferSize--;
if(mRequestedSize == 1) mRequestedDiscard = 0;
else memcpy(buffer + cur_size, mBuffer+1, mRequestedSize-1); // append
} }
memcpy(buffer + cur_size, mBuffer, mRequestedSize); // append else memcpy(buffer + cur_size, mBuffer, mRequestedSize); // append
// NOTE: setData releases current data and owns new data (buffer) // NOTE: setData releases current data and owns new data (buffer)
mFormattedImage->setData(buffer, mBufferSize); mFormattedImage->setData(buffer, mBufferSize);
// delete temp data // delete temp data
@@ -1820,7 +1824,11 @@ S32 LLTextureFetchWorker::callbackHttpGet(const LLChannelDescriptors& channels,
mBuffer = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), data_size); mBuffer = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), data_size);
buffer->readAfter(channels.in(), NULL, mBuffer, data_size); buffer->readAfter(channels.in(), NULL, mBuffer, data_size);
mBufferSize += data_size; mBufferSize += data_size;
if (data_size < mRequestedSize && mRequestedDiscard == 0) if(mFormattedImage.notNull() && mFormattedImage->getDataSize() > 0 && data_size == 1)
{
mHaveAllData = TRUE;
}
else if (data_size < mRequestedSize && mRequestedDiscard == 0)
{ {
mHaveAllData = TRUE; mHaveAllData = TRUE;
} }