use a linked list instead of array for saved messages to fix problems when Dispatch() is reentered (part of patch 1080770)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30950 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2004-12-12 11:47:57 +00:00
parent 18dbea4d81
commit 9af08eb826

View File

@@ -44,12 +44,12 @@
#if wxUSE_THREADS #if wxUSE_THREADS
#include "wx/thread.h" #include "wx/thread.h"
// define the array of MSG strutures // define the list of MSG strutures
WX_DECLARE_OBJARRAY(MSG, wxMsgArray); WX_DECLARE_LIST(MSG, wxMsgList);
#include "wx/arrimpl.cpp" #include "wx/listimpl.cpp"
WX_DEFINE_OBJARRAY(wxMsgArray); WX_DEFINE_LIST(wxMsgList);
#endif // wxUSE_THREADS #endif // wxUSE_THREADS
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -337,7 +337,7 @@ bool wxEventLoop::Dispatch()
wxT("only the main thread can process Windows messages") ); wxT("only the main thread can process Windows messages") );
static bool s_hadGuiLock = true; static bool s_hadGuiLock = true;
static wxMsgArray s_aSavedMessages; static wxMsgList s_aSavedMessages;
// if a secondary thread owning the mutex is doing GUI calls, save all // if a secondary thread owning the mutex is doing GUI calls, save all
// messages for later processing - we can't process them right now because // messages for later processing - we can't process them right now because
@@ -350,7 +350,8 @@ bool wxEventLoop::Dispatch()
// the message will be processed twice // the message will be processed twice
if ( !wxIsWaitingForThread() || msg.message != WM_COMMAND ) if ( !wxIsWaitingForThread() || msg.message != WM_COMMAND )
{ {
s_aSavedMessages.Add(msg); MSG* pMsg = new MSG(msg);
s_aSavedMessages.Append(pMsg);
} }
return true; return true;
@@ -366,14 +367,17 @@ bool wxEventLoop::Dispatch()
{ {
s_hadGuiLock = true; s_hadGuiLock = true;
size_t count = s_aSavedMessages.Count(); wxMsgList::compatibility_iterator node = s_aSavedMessages.GetFirst();
for ( size_t n = 0; n < count; n++ ) while (node)
{ {
MSG& msg = s_aSavedMessages[n]; MSG* pMsg = node->GetData();
ProcessMessage(&msg); s_aSavedMessages.Erase(node);
}
s_aSavedMessages.Empty(); ProcessMessage(pMsg);
delete pMsg;
node = s_aSavedMessages.GetFirst();
}
} }
} }
#endif // wxUSE_THREADS #endif // wxUSE_THREADS