From 192e8befb8edb65448a5af08d02ff9376bc9b3ce Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 1 Jun 2020 15:04:45 +0200 Subject: [PATCH] Fix example showing wxMutex usage in documentation Fix wrong use of pointer and wrong variable name. Closes #18778. --- interface/wx/thread.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/interface/wx/thread.h b/interface/wx/thread.h index 2ee4a1de72..9eedf87a42 100644 --- a/interface/wx/thread.h +++ b/interface/wx/thread.h @@ -1586,7 +1586,7 @@ enum wxMutexError // this variable has an "s_" prefix because it is static: seeing an "s_" in // a multithreaded program is in general a good sign that you should use a // mutex (or a critical section) - static wxMutex *s_mutexProtectingTheGlobalData; + static wxMutex s_mutexProtectingTheGlobalData; // we store some numbers in this global array which is presumably used by // several threads simultaneously @@ -1595,11 +1595,15 @@ enum wxMutexError void MyThread::AddNewNode(int num) { // ensure that no other thread accesses the list - s_mutexProtectingTheGlobalList->Lock(); + + // Note that using Lock() and Unlock() explicitly is not recommended + // and only done here for illustrative purposes, prefer to use + // wxMutexLocker, as shown below, instead! + s_mutexProtectingTheGlobalData.Lock(); s_data.Add(num); - s_mutexProtectingTheGlobalList->Unlock(); + s_mutexProtectingTheGlobaData.Unlock(); } // return true if the given number is greater than all array elements