1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Do not crash on invalid callback name

This commit is contained in:
Ivan Savenko 2023-03-31 01:28:33 +03:00
parent 4f703df4ac
commit 6e28b6ed90

View File

@ -297,7 +297,14 @@ std::shared_ptr<CToggleButton> InterfaceObjectConfigurable::buildToggleButton(co
button->setImageOrder(imgOrder[0].Integer(), imgOrder[1].Integer(), imgOrder[2].Integer(), imgOrder[3].Integer());
}
if(!config["callback"].isNull())
button->addCallback(callbacks.at(config["callback"].String()));
{
std::string callbackName = config["callback"].String();
if (callbacks.count(callbackName))
button->addCallback(callbacks.at(callbackName));
else
logGlobal->error("Invalid callback '%s' in widget", callbackName );
}
return button;
}