From 2cf9f046a6135edd970001a2820c2e8250d763a0 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Thu, 7 Jul 2022 20:50:56 +0300
Subject: [PATCH] SL-17545 lodQueryCallback should quit as soon as it is done

---
 indra/newview/llmodelpreview.cpp | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp
index 2920521d317..3bca4fde83e 100644
--- a/indra/newview/llmodelpreview.cpp
+++ b/indra/newview/llmodelpreview.cpp
@@ -842,15 +842,17 @@ void LLModelPreview::clearIncompatible(S32 lod)
     if (replaced_base_model && !mGenLOD)
     {
         // In case base was replaced, we might need to restart generation
+
+        // Check if already started
         bool subscribe_for_generation = mLodsQuery.empty();
-        if (lod == LLModel::LOD_HIGH)
-        {
-            mLodsQuery.clear();
-        }
+        
+        // Remove previously scheduled work
+        mLodsQuery.clear();
 
         LLFloaterModelPreview* fmp = LLFloaterModelPreview::sInstance;
         if (!fmp) return;
 
+        // Schedule new work
         for (S32 i = LLModel::LOD_HIGH; i >= 0; --i)
         {
             if (mModel[i].empty())
@@ -867,6 +869,7 @@ void LLModelPreview::clearIncompatible(S32 lod)
             }
         }
 
+        // Subscribe if we have pending work and not subscribed yet
         if (!mLodsQuery.empty() && subscribe_for_generation)
         {
             doOnIdleRepeating(lodQueryCallback);
@@ -3860,7 +3863,7 @@ bool LLModelPreview::lodQueryCallback()
             }
 
             // return false to continue cycle
-            return false;
+            return preview->mLodsQuery.empty();
         }
     }
     // nothing to process
-- 
GitLab