use critical section to protect global TablesInUse (patch 1660652) [backport from HEAD]

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@44643 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-03-07 21:29:30 +00:00
parent 0c2aec0e8f
commit e62a53c7f6
2 changed files with 32 additions and 22 deletions

View File

@@ -60,6 +60,7 @@ ULONG lastTableID = 0;
#ifdef __WXDEBUG__
wxList TablesInUse;
wxCriticalSection csTablesInUse;
#endif
@@ -195,7 +196,10 @@ bool wxDbTable::initialize(wxDb *pwxDb, const wxString &tblName, const UWORD num
tableInUse->tableName = tblName;
tableInUse->tableID = tableID;
tableInUse->pDb = pDb;
TablesInUse.Append(tableInUse);
{
wxCriticalSectionLocker lock(csTablesInUse);
TablesInUse.Append(tableInUse);
}
#endif
pDb->WriteSqlLog(s);
@@ -321,17 +325,20 @@ void wxDbTable::cleanup()
bool found = false;
wxList::compatibility_iterator pNode;
pNode = TablesInUse.GetFirst();
while (pNode && !found)
{
if (((wxTablesInUse *)pNode->GetData())->tableID == tableID)
wxCriticalSectionLocker lock(csTablesInUse);
pNode = TablesInUse.GetFirst();
while (!found && pNode)
{
found = true;
delete (wxTablesInUse *)pNode->GetData();
TablesInUse.Erase(pNode);
if (((wxTablesInUse *)pNode->GetData())->tableID == tableID)
{
found = true;
delete (wxTablesInUse *)pNode->GetData();
TablesInUse.Erase(pNode);
}
else
pNode = pNode->GetNext();
}
else
pNode = pNode->GetNext();
}
if (!found)
{