use critical section to protect global TablesInUse (patch 1660652)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44642 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -63,6 +63,7 @@ wxChar const *SQL_CATALOG_FILENAME = wxT("catalog.txt");
|
|||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
extern wxList TablesInUse;
|
extern wxList TablesInUse;
|
||||||
|
extern wxCriticalSection csTablesInUse;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// SQL Log defaults to be used by GetDbConnection
|
// SQL Log defaults to be used by GetDbConnection
|
||||||
@@ -1746,6 +1747,8 @@ void wxDb::Close(void)
|
|||||||
wxASSERT(nTables == 0);
|
wxASSERT(nTables == 0);
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker lock(csTablesInUse);
|
||||||
wxTablesInUse *tiu;
|
wxTablesInUse *tiu;
|
||||||
wxList::compatibility_iterator pNode;
|
wxList::compatibility_iterator pNode;
|
||||||
pNode = TablesInUse.GetFirst();
|
pNode = TablesInUse.GetFirst();
|
||||||
@@ -1762,6 +1765,7 @@ void wxDb::Close(void)
|
|||||||
}
|
}
|
||||||
pNode = pNode->GetNext();
|
pNode = pNode->GetNext();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Copy the error messages to a global variable
|
// Copy the error messages to a global variable
|
||||||
@@ -2306,7 +2310,6 @@ bool wxDb::ExecSql(const wxString &pSqlStmt, wxDbColInf** columns, short& numcol
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pColInf[colNum].sqlDataType = Sqllen;
|
|
||||||
switch (Sqllen)
|
switch (Sqllen)
|
||||||
{
|
{
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
|
@@ -60,6 +60,7 @@ ULONG lastTableID = 0;
|
|||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
wxList TablesInUse;
|
wxList TablesInUse;
|
||||||
|
wxCriticalSection csTablesInUse;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -182,7 +183,10 @@ bool wxDbTable::initialize(wxDb *pwxDb, const wxString &tblName, const UWORD num
|
|||||||
tableInUse->tableName = tblName;
|
tableInUse->tableName = tblName;
|
||||||
tableInUse->tableID = tableID;
|
tableInUse->tableID = tableID;
|
||||||
tableInUse->pDb = pDb;
|
tableInUse->pDb = pDb;
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker lock(csTablesInUse);
|
||||||
TablesInUse.Append(tableInUse);
|
TablesInUse.Append(tableInUse);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pDb->WriteSqlLog(s);
|
pDb->WriteSqlLog(s);
|
||||||
@@ -308,8 +312,10 @@ void wxDbTable::cleanup()
|
|||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
wxList::compatibility_iterator pNode;
|
wxList::compatibility_iterator pNode;
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker lock(csTablesInUse);
|
||||||
pNode = TablesInUse.GetFirst();
|
pNode = TablesInUse.GetFirst();
|
||||||
while (pNode && !found)
|
while (!found && pNode)
|
||||||
{
|
{
|
||||||
if (((wxTablesInUse *)pNode->GetData())->tableID == tableID)
|
if (((wxTablesInUse *)pNode->GetData())->tableID == tableID)
|
||||||
{
|
{
|
||||||
@@ -320,6 +326,7 @@ void wxDbTable::cleanup()
|
|||||||
else
|
else
|
||||||
pNode = pNode->GetNext();
|
pNode = pNode->GetNext();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
Reference in New Issue
Block a user