diff --git a/src/auto4_lua_assfile.cpp b/src/auto4_lua_assfile.cpp index 9d5bb25ab..b908ecf35 100644 --- a/src/auto4_lua_assfile.cpp +++ b/src/auto4_lua_assfile.cpp @@ -125,8 +125,8 @@ namespace { } template - T check_cast(U value) { - return typeid(T) == typeid(value) ? static_cast(value) : nullptr; + const T *check_cast_constptr(const U *value) { + return typeid(const T) == typeid(*value) ? static_cast(value) : nullptr; } } @@ -155,13 +155,13 @@ namespace Automation4 { set_field(L, "section", e->GroupHeader()); - if (auto info = check_cast(e)) { + if (auto info = check_cast_constptr(e)) { set_field(L, "raw", info->GetEntryData()); set_field(L, "key", info->Key()); set_field(L, "value", info->Value()); set_field(L, "class", "info"); } - else if (auto dia = check_cast(e)) { + else if (auto dia = check_cast_constptr(e)) { set_field(L, "raw", dia->GetEntryData()); set_field(L, "comment", dia->Comment); @@ -192,7 +192,7 @@ namespace Automation4 { set_field(L, "class", "dialogue"); } - else if (auto sty = check_cast(e)) { + else if (auto sty = check_cast_constptr(e)) { set_field(L, "raw", sty->GetEntryData()); set_field(L, "name", sty->name); @@ -623,7 +623,7 @@ namespace Automation4 { int LuaAssFile::LuaParseKaraokeData(lua_State *L) { auto e = LuaToAssEntry(L, ass); - auto dia = check_cast(e.get()); + auto dia = check_cast_constptr(e.get()); argcheck(L, !!dia, 1, "Subtitle line must be a dialogue line"); int idx = 0;