From 05115e1ef88d62d06b7ac4529a1a590276a5415d Mon Sep 17 00:00:00 2001 From: Armin Weatherwax Date: Tue, 2 Mar 2010 14:09:41 +0100 Subject: Aleric Inglewood: SNOW-408 Fix the case for a non-valid handle but abort set. --- linden/doc/contributions.txt | 2 ++ linden/indra/newview/lltexturecache.cpp | 43 +++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 15 deletions(-) (limited to 'linden') diff --git a/linden/doc/contributions.txt b/linden/doc/contributions.txt index 7b7d313..253c157 100644 --- a/linden/doc/contributions.txt +++ b/linden/doc/contributions.txt @@ -40,6 +40,7 @@ Aimee Trescothick Alejandro Rosenthal VWR-1184 Aleric Inglewood + SNOW-408 VWR-10759 VWR-10837 Alissa Sabre @@ -68,6 +69,7 @@ Alissa Sabre VWR-2826 VWR-3290 VWR-3410 + SNOW-408 VWR-3857 VWR-4010 VWR-5575 diff --git a/linden/indra/newview/lltexturecache.cpp b/linden/indra/newview/lltexturecache.cpp index e0bef61..706e408 100644 --- a/linden/indra/newview/lltexturecache.cpp +++ b/linden/indra/newview/lltexturecache.cpp @@ -1484,26 +1484,39 @@ LLTextureCache::handle_t LLTextureCache::readFromCache(const LLUUID& id, U32 pri return handle; } - +// Return true if the handle is not valid, which is the case +// when the worker was already deleted or is scheduled for deletion. +// +// If the handle exists and a call to worker->complete() returns +// true or abort is true, then the handle is removed and the worker +// scheduled for deletion. bool LLTextureCache::readComplete(handle_t handle, bool abort) { - lockWorkers(); + lockWorkers(); // Needed for access to mReaders. + handle_map_t::iterator iter = mReaders.find(handle); - llassert_always(iter != mReaders.end() || abort); - LLTextureCacheWorker* worker = iter->second; - bool res = worker->complete(); - if (res || abort) - { - mReaders.erase(handle); - unlockWorkers(); - worker->scheduleDelete(); - return true; - } - else + bool handle_is_valid = iter != mReaders.end(); + llassert_always(handle_is_valid || abort); + LLTextureCacheWorker* worker = NULL; + bool delete_worker = false; + + if (handle_is_valid) { - unlockWorkers(); - return false; + worker = iter->second; + delete_worker = worker->complete() || abort; + if (delete_worker) + { + mReaders.erase(handle); + handle_is_valid = false; + } } + + unlockWorkers(); + + if (delete_worker) worker->scheduleDelete(); + + // Return false if the handle is (still) valid. + return !handle_is_valid; } LLTextureCache::handle_t LLTextureCache::writeToCache(const LLUUID& id, U32 priority, -- cgit v1.1