https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5f8a10f32b0ce06e8cd2f1d445272bd790ebc670

commit 5f8a10f32b0ce06e8cd2f1d445272bd790ebc670
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Fri Sep 17 19:16:02 2021 +0200
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Sun Sep 19 00:17:05 2021 +0200

    [BROWSEUI] CAutoComplete::OnAutoCompStart(): Wait on the thread only when 
there is a handle.
    
    Avoids spamming
    (ntoskrnl\ob\obwait.c:441) Failed to reference the handle with status 
0xc0000008
    
    CAutoComplete::FinishCompletion(): Remove two useless 'if (m_pThread || 
!m_hThread)'
    tests: No need to check these after each code instruction...
---
 dll/win32/browseui/CAutoComplete.cpp | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/dll/win32/browseui/CAutoComplete.cpp 
b/dll/win32/browseui/CAutoComplete.cpp
index 2b33198a5fe..6ff30edcefc 100644
--- a/dll/win32/browseui/CAutoComplete.cpp
+++ b/dll/win32/browseui/CAutoComplete.cpp
@@ -2092,13 +2092,16 @@ LRESULT CAutoComplete::OnAutoCompStart(UINT uMsg, 
WPARAM wParam, LPARAM lParam,
         delete pOld;
 
     BOOL bDoStart = FALSE;
-    DWORD dwWait = WaitForSingleObject(m_hThread, 0);
-    if (dwWait != WAIT_TIMEOUT)
+    if (m_hThread)
     {
-        CloseHandle(m_hThread);
-        bDoStart = TRUE;
+        if (WaitForSingleObject(m_hThread, 0) != WAIT_TIMEOUT)
+        {
+            CloseHandle(m_hThread);
+            m_hThread = NULL;
+            bDoStart = TRUE;
+        }
     }
-    else if (!m_hThread)
+    else
     {
         bDoStart = TRUE;
     }
@@ -2131,15 +2134,9 @@ VOID CAutoComplete::FinishCompletion(PAC_THREAD pThread)
     if (!CanAutoSuggest() && !CanAutoAppend())
         return;
 
-    if (m_pThread || !m_hThread)
-        return;
-
     // set inner list
     m_innerList = pThread->m_innerList;
 
-    if (m_pThread || !m_hThread)
-        return;
-
     // set the items of the virtual listview
     m_outerList = pThread->m_outerList; // FIXME: We need more speed!
     m_hwndList.SendMessageW(LVM_SETITEMCOUNT, m_outerList.GetSize(), 0);

Reply via email to