Coverity defects

qt6_macos
uramer 1 year ago
parent c1e8e88914
commit e9b48e35c0

@ -76,7 +76,7 @@ namespace MWLua
inputActions[sol::meta_function::pairs] = pairs;
}
auto actionInfo = context.mLua->sol().new_usertype<LuaUtil::InputAction::Info>("ActionInfo", "key",
context.mLua->sol().new_usertype<LuaUtil::InputAction::Info>("ActionInfo", "key",
sol::property([](const LuaUtil::InputAction::Info& info) { return info.mKey; }), "name",
sol::property([](const LuaUtil::InputAction::Info& info) { return info.mName; }), "description",
sol::property([](const LuaUtil::InputAction::Info& info) { return info.mDescription; }), "type",
@ -102,7 +102,7 @@ namespace MWLua
inputTriggers[sol::meta_function::pairs] = pairs;
}
auto triggerInfo = context.mLua->sol().new_usertype<LuaUtil::InputTrigger::Info>("TriggerInfo", "key",
context.mLua->sol().new_usertype<LuaUtil::InputTrigger::Info>("TriggerInfo", "key",
sol::property([](const LuaUtil::InputTrigger::Info& info) { return info.mKey; }), "name",
sol::property([](const LuaUtil::InputTrigger::Info& info) { return info.mName; }), "description",
sol::property([](const LuaUtil::InputTrigger::Info& info) { return info.mDescription; }), "l10n",
@ -127,7 +127,7 @@ namespace MWLua
parsedOptions.mName = options["name"].get<std::string_view>();
parsedOptions.mDescription = options["description"].get<std::string_view>();
parsedOptions.mDefaultValue = options["defaultValue"].get<sol::main_object>();
manager->inputActions().insert(parsedOptions);
manager->inputActions().insert(std::move(parsedOptions));
};
api["bindAction"] = [manager = context.mLuaManager](
std::string_view key, const sol::table& callback, sol::table dependencies) {
@ -164,7 +164,7 @@ namespace MWLua
parsedOptions.mL10n = options["l10n"].get<std::string_view>();
parsedOptions.mName = options["name"].get<std::string_view>();
parsedOptions.mDescription = options["description"].get<std::string_view>();
manager->inputTriggers().insert(parsedOptions);
manager->inputTriggers().insert(std::move(parsedOptions));
};
api["registerTriggerHandler"]
= [manager = context.mLuaManager](std::string_view key, const sol::table& callback) {

@ -113,7 +113,7 @@ namespace LuaUtil
}
}
void Registry::insert(Info info)
void Registry::insert(const Info& info)
{
if (mIds.find(info.mKey) != mIds.end())
throw std::domain_error(Misc::StringUtils::format("Action key \"%s\" is already in use", info.mKey));
@ -251,7 +251,7 @@ namespace LuaUtil
return it->second;
}
void Registry::insert(Info info)
void Registry::insert(const Info& info)
{
if (mIds.find(info.mKey) != mIds.end())
throw std::domain_error(Misc::StringUtils::format("Trigger key \"%s\" is already in use", info.mKey));

@ -60,7 +60,7 @@ namespace LuaUtil::InputAction
{
public:
using ConstIterator = std::vector<Info>::const_iterator;
void insert(Info info);
void insert(const Info& info);
size_t size() const { return mKeys.size(); }
std::optional<std::string> firstKey() const { return mKeys.empty() ? std::nullopt : std::optional(mKeys[0]); }
std::optional<std::string> nextKey(std::string_view key) const;
@ -127,7 +127,7 @@ namespace LuaUtil::InputTrigger
return it->first;
}
std::optional<Info> operator[](std::string_view key);
void insert(Info info);
void insert(const Info& info);
void registerHandler(std::string_view key, const LuaUtil::Callback& callback);
void activate(std::string_view key);
void clear()

Loading…
Cancel
Save