1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-01-18 19:47:15 +01:00

Update Data.cpp

Make callback processing more robust
This commit is contained in:
Sandu Liviu Catalin 2021-02-09 15:21:26 +02:00
parent c9dbd38255
commit b897cde9e5

View File

@ -427,15 +427,18 @@ static void Register_POCO_Data_Binding(HSQUIRRELVM vm, Table & ns, const SQChar
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
static void ProcessPocoData(SQInteger ms) static void ProcessPocoData()
{ {
// Go over all statement results and try to update them // Go over all statement results and try to update them
for (SqDataStatementResult * inst = SqDataStatementResult::sHead; inst && inst->mNext != SqDataStatementResult::sHead; inst = inst->mNext) for (SqDataStatementResult * inst = SqDataStatementResult::sHead; inst && inst->mNext != SqDataStatementResult::sHead; inst = inst->mNext)
{ {
if (inst->mRes.tryWait(static_cast< long >(ms))) if (inst->mRes.available())
{ {
// Forward the callback with the result // Forward the callback with the result
inst->mFunc(inst->mStmt, inst->mRes.data()); if (!inst->mFunc.IsNull())
{
inst->mFunc.Execute(inst->mStmt, inst->mRes.data());
}
// Stop processing this result // Stop processing this result
inst->UnchainInstance(); inst->UnchainInstance();
// Release script resources // Release script resources