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

@@ -63,6 +63,7 @@ wxChar const *SQL_CATALOG_FILENAME = wxT("catalog.txt");
#ifdef __WXDEBUG__
extern wxList TablesInUse;
extern wxCriticalSection csTablesInUse;
#endif
// SQL Log defaults to be used by GetDbConnection
@@ -1746,21 +1747,24 @@ void wxDb::Close(void)
wxASSERT(nTables == 0);
#ifdef __WXDEBUG__
wxTablesInUse *tiu;
wxList::compatibility_iterator pNode;
pNode = TablesInUse.GetFirst();
wxString s,s2;
while (pNode)
{
tiu = (wxTablesInUse *)pNode->GetData();
if (tiu->pDb == this)
wxCriticalSectionLocker lock(csTablesInUse);
wxTablesInUse *tiu;
wxList::compatibility_iterator pNode;
pNode = TablesInUse.GetFirst();
wxString s,s2;
while (pNode)
{
s.Printf(wxT("(%-20s) tableID:[%6lu] pDb:[%p]"),
tiu->tableName, tiu->tableID, wx_static_cast(void*, tiu->pDb));
s2.Printf(wxT("Orphaned table found using pDb:[%p]"), wx_static_cast(void*, this));
wxLogDebug(s.c_str(),s2.c_str());
tiu = (wxTablesInUse *)pNode->GetData();
if (tiu->pDb == this)
{
s.Printf(wxT("(%-20s) tableID:[%6lu] pDb:[%p]"),
tiu->tableName, tiu->tableID, wx_static_cast(void*, tiu->pDb));
s2.Printf(wxT("Orphaned table found using pDb:[%p]"), wx_static_cast(void*, this));
wxLogDebug(s.c_str(),s2.c_str());
}
pNode = pNode->GetNext();
}
pNode = pNode->GetNext();
}
#endif
@@ -2306,7 +2310,6 @@ bool wxDb::ExecSql(const wxString &pSqlStmt, wxDbColInf** columns, short& numcol
return false;
}
pColInf[colNum].sqlDataType = Sqllen;
switch (Sqllen)
{
#if wxUSE_UNICODE