fix crash with asset scripts that only manifested after MSVC update

This commit is contained in:
Kae 2024-06-03 18:28:51 +10:00
parent 5d1e85b241
commit 5a99d7b245

View File

@ -151,7 +151,7 @@ Assets::Assets(Settings settings, StringList assetSources) {
// re-add the assets callbacks with more functions
context.remove("assets");
auto callbacks = makeBaseAssetCallbacks();
callbacks.registerCallback("add", [&newFiles](LuaEngine& engine, String const& path, LuaValue const& data) {
callbacks.registerCallback("add", [newFiles](LuaEngine& engine, String const& path, LuaValue const& data) {
ByteArray bytes;
if (auto str = engine.luaMaybeTo<String>(data))
bytes = ByteArray(str->utf8Ptr(), str->utf8Size());
@ -165,7 +165,7 @@ Assets::Assets(Settings settings, StringList assetSources) {
newFiles->set(path, bytes);
});
callbacks.registerCallback("patch", [this, &newFiles](String const& path, String const& patchPath) -> bool {
callbacks.registerCallback("patch", [this, newFiles](String const& path, String const& patchPath) -> bool {
if (auto file = m_files.ptr(path)) {
if (newFiles->contains(patchPath)) {
file->patchSources.append(make_pair(patchPath, newFiles));