fix missing Lua error messages in ResultCheckThread

This commit is contained in:
Lion Kortlepel 2022-07-20 16:07:00 +02:00
parent f21d3d0389
commit 8b57f6e35a
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B
2 changed files with 9 additions and 6 deletions

View File

@ -12,6 +12,7 @@
- FIXED onInit not being called on hot-reload - FIXED onInit not being called on hot-reload
- FIXED incorrect timing calculation of Lua EventTimer loop - FIXED incorrect timing calculation of Lua EventTimer loop
- FIXED bug which caused hot-reload not to report syntax errors - FIXED bug which caused hot-reload not to report syntax errors
- FIXED missing error messages on some event handler calls
# v3.0.2 # v3.0.2

View File

@ -59,19 +59,21 @@ void TLuaEngine::operator()() {
RegisterThread("ResultCheckThread"); RegisterThread("ResultCheckThread");
while (!Application::IsShuttingDown()) { while (!Application::IsShuttingDown()) {
std::unique_lock Lock(mResultsToCheckMutex); std::unique_lock Lock(mResultsToCheckMutex);
mResultsToCheckCond.wait_for(Lock, std::chrono::milliseconds(20)); beammp_tracef("Results to check: {}", mResultsToCheck.size());
if (!mResultsToCheck.empty()) { if (!mResultsToCheck.empty()) {
mResultsToCheck.remove_if([](const std::shared_ptr<TLuaResult>& Ptr) -> bool { mResultsToCheck.remove_if([](const std::shared_ptr<TLuaResult>& Ptr) -> bool {
if (Ptr->Ready) { if (Ptr->Ready) {
return true; if (Ptr->Error) {
} else if (Ptr->Error) {
if (Ptr->ErrorMessage != BeamMPFnNotFoundError) { if (Ptr->ErrorMessage != BeamMPFnNotFoundError) {
beammp_lua_error(Ptr->Function + ": " + Ptr->ErrorMessage); beammp_lua_error(Ptr->Function + ": " + Ptr->ErrorMessage);
} }
}
return true; return true;
} }
return false; return false;
}); });
} else {
mResultsToCheckCond.wait_for(Lock, std::chrono::milliseconds(20));
} }
} }
}); });
@ -161,7 +163,7 @@ void TLuaEngine::AddResultToCheck(const std::shared_ptr<TLuaResult>& Result) {
mResultsToCheckCond.notify_one(); mResultsToCheckCond.notify_one();
} }
std::unordered_map<std::string /*event name */, std::vector<std::string> /* handlers */> TLuaEngine::Debug_GetEventsForState(TLuaStateId StateId) { std::unordered_map<std::string /* event name */, std::vector<std::string> /* handlers */> TLuaEngine::Debug_GetEventsForState(TLuaStateId StateId) {
std::unordered_map<std::string, std::vector<std::string>> Result; std::unordered_map<std::string, std::vector<std::string>> Result;
std::unique_lock Lock(mLuaEventsMutex); std::unique_lock Lock(mLuaEventsMutex);
for (const auto& EventNameToEventMap : mLuaEvents) { for (const auto& EventNameToEventMap : mLuaEvents) {